Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Records: syntax error...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: chris.danx <chris.danx@n...>
Subject: [Caml-list] Records: syntax error...

I'm working my way through the ocaml book, and came across one exercise 
I can't get to work (sort of).  The exercise asked to define insert over 
the following type

type 'a dList =
   {l: 'a list; compare : 'a -> 'a -> bool; in_order : bool};;

I can get it to work with code similar to the solution, but since I had 
defined a merge function in the same file I decided to try using pattern 
matching on the record...

let insert item dl =
   match dl with
       {l = _; compare = _; in_order = true}  ->
               {merge (dl.l, [item]),, true}
     | {l = _; compare = _; in_order = false} ->
               {item::dl.l,, false};;

but ocaml complains of a syntax error at  What did I do wrong?


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: