On 7/19/06, Jonathan Roewen <jonathan.roewen@gmail.com> wrote:
> let receive idList msg =
>   match message with
>      None -> None
>
> |    Register( REQUEST_KEY, id ) -> begin
>          match idList with
>              [] -> Register(SUCCESS, id)
>          |   l when (List.mem id l) -> Register(Success, (next_available_id
> l))
>          |  _ -> Register(Success, id)
> ;;

For the inner match, why you even both with it is beyond me. All you
are doing is wrapping List.mem in an unnecessary test.

It should be:
| Register(REQUEST_KEY,id) ->
   if List.mem id idList then
      Register(Success, next_available_id l)
   else
      Register(Success, id)

Perhaps the fact that your example makes no sense (it's not a complete
definition, nor is Success defined anywhere, nor does Register even
accept the constructor Success) doesn't help here.


The main purpose is not to actually construct a program but to construct a specification of a communications protocol in a syntax that I can give to a non-coder and have them read but also have some validation that I'm checking all possible cases.

You are correct in your statement that the match isn't necessary but that's assuming that I care about the program.  The match is much more explicit to a non-coder (at least that's the feedback I've gotten) of the case that we''re trying to test.