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?

Book: https://caml.inria.fr/pub/docs/oreilly-book/ocaml-ora-book.pdf
My gist: https://gist.github.com/wyn/381419bee4d1c60891c51a2b0acff1f5

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.

thanks

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.

Thanks

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: http://www.research.microsoft.com/~conan/fran/ doesn’t seem to be there anymore.

Same for this link:
http://www.cs.chalmers.se/ComputingScience/Research/Functional/Fudgets/

Still on page 145, the Hump link doesn’t exist anymore: http://caml.inria.fr/hump.html

Link: https://www.irif.fr/users/emmanuel/Public/enseignement/VRcaML also doesn’t exist anymore

Same for the link: http://www.cryo-networks.com

Page 211, dead link again: http://caml.inria.fr/camlstone.txt

Page 239: The CamlDBM library is now distributed separately: https://github.com/ocaml/dbm

Page 246: http://theory.lcs.mit.edu/~rivest/homepage.html probably became: http://people.csail.mit.edu/rivest/

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.