Code review: chapter 14 exercises of ORA book

Hello all,

I’m looking to see if any kind people out there might give me some review of my solutions to the Ocaml ORA book’s chapter 14 exercises?

My gist:

looking for gotchas, bad practises to avoid etc

A specific question I had was with ex3 Lexical parser: I found I had to put two function (from_string and to_string) into WORD sig. I felt that I shouldn’t have needed to do this ? That I should have been able to tell the functor LexTree what W.alpha was? Basically a bit confused about sharing constraints and exposing/not exposing types to the outside world.


There is also an online HTML rendering of the book, and in particular the Chapter 14 exercises.

I haven’t looked at the whole code but there is a difference with the Association Lists requirements: the exercises asks for a functional/immutable interface, but your add/delete functions are imperative, they return unit – and indeed your implementation had to wrap the value in a mutable cell. Is this difference intentional?

That is a good point, I think I just forgot that requirement whilst in the thick of it all. I’ll have a look tonight and do it without mutation.


ok have updated the gist with an immutable implementation for ex1 - also noticed my use of != instead of <> in the delete function…eek.

The explanation of the type string (page 72) is not up to date with the last ocaml versions where this type is became immutable.

The example page 93 also assumes strings are still mutable.

page 118 missing a space between executable and mytoplevel.

Page 145 the link: doesn’t seem to be there anymore.

Same for this link:

Still on page 145, the Hump link doesn’t exist anymore:

Link: also doesn’t exist anymore

Same for the link:

Page 211, dead link again:

Page 239: The CamlDBM library is now distributed separately:

Page 246: probably became:

Thanks fccm,

I guess the book itself is a bit outdated but I thought the chapter on modules and functors was still relevant? Also I hadn’t realised one could use module sigs as different views on a larger struct. I thought that was pretty neat but maybe that is bad practise?

Anyway - to be clear I was trying to get some help with my solutions to chapter 14 exercises, I understand some aspects of the book might be out of date.