Loading ...
Sorry, an error occurred while loading the content.

9683Re: "ocaml_beginners"::[] Writing to many files

Expand Messages
  • William D. Neumann
    Apr 22, 2008
      On Tue, 22 Apr 2008 11:39:51 +0200, Johann Spies wrote

      > I have adapted your code because I want to use two different output
      > files. My code produces an error which I do not understand:
      >
      > Characters 226-250:
      > This pattern matches values of type 'a option * 'b option * 'c option
      > but is here used to match values of type 'd option * 'e option
      >
      > The code:
      >
      > let last_date = ref None
      > and last_auth = ref None
      > and last_acc = ref None
      >
      > let outputfile date =
      > match !last_date,!last_auth, !last_acc with
      > | Some d, Some oc when d = date, Some ot -> oc,ot
      > | Some d, None when d = date, None ->

      The problem is in these last two lines. The when clause has to come after
      the entire pattern, not in the middle of it. change those two lines to the
      following and it works:

      | Some d, Some oc , Some ot when d = date -> oc,ot
      | Some d, None, None when d = date ->

      See chapter 6 of the manual for more detail.

      --

      William D. Neumann
    • Show all 17 messages in this topic