Try something like
match idList with
[] -> Register(SUCCESS, id)
| l -> if List.mem id l then Register(foo) else Register(bar)
And replace the guard with an if statement.
--
Seth Fogarty sfogarty@[gmail.com|rice.edu|livejournal]
Neep-neep at large AIM: Sorrath
"I know there are people in this world who do not love their fellow
human beings - and I hate people like that" --Tom Lehrer.
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
To avoid | _ -> ... matching clauses, have a look at the -w E warning.
<http://caml.inria.fr/pub/docs/manual-ocaml/manual022.html>
Section 8.2 'Options'
I cannot get your exact point, besides the above code does not even go through
parsing (missing end), let -> type etc.
In fact what you want to achieve is still unclear.
As regards your message and requestOp types there should be no problem,
Something like
match msg with
| None -> ...
| Register (REQUEST_KEY, id) -> ...
| Register (SUCCESS, id) -> ...
Is easily shown to be exhaustive.
As regards your list example, perhaps you'd like better
match idList with
| [] -> Register(SUCCESS, id)
| _::_ ->
if List.mem id idList then Register(SUCCESS, next_available idList)
else Register(SUCCESS, id)
or even
match idList with
| [] -> Register(SUCCESS, id)
| _::_ when List.mem id idList -> Register(SUCCESS, next_available idList)
| _::_ -> Register(SUCCESS, id)
Both are easily shown to be exhaustive, but frankly, this brings you
no more guarantee than the much more direct code
if List.mem id idList then
Register(SUCCESS, next_available_id idList))
else
Register (SUCESS, id)
--
Luc Maranget