From: "Johan Georg Granström" <georg.g@home.se>
To: "Jeff Polakow" <jpolakow@gnp.com>
Cc: <caml-list@inria.fr>
Subject: Re: [Caml-list] strange match error
Date: Tue, 12 Mar 2002 00:35:48 +0100 [thread overview]
Message-ID: <018d01c1c955$79451c20$e08c72d5@invariant.se> (raw)
In-Reply-To: <3C8D30CA.C8CAAD91@gnp.com>
Jeff,
> I ran into a strange (I think) error and was wondering if someone
> out there can help me out.
>
> Why does the following program:
> type tt = A of string * int | B;;
> let f x = print_string ((fst x)^"\n");;
> let g x = match x with A y -> f y | B -> ();;
>
> produce the following response from ocaml?
> # #use "caml_test.ml";;
> type tt = A of string * int | B
> val f : string * 'a -> unit = <fun>
> File "caml_test.ml", line 3, characters 23-26:
> The constructor A expects 2 argument(s), but is here applied to 1
> argument(s)
>
> Shouldn't the type reconstructor/checker realize that y is a pair?
Nope, since it isn't. Try
type tt = A of (string * int) | B;;
if you want A to be of one argument, a pair.
The syntax is a bit obscure here...
In revised syntax, the first would read
type tt = [A of string and int | B];
and the second
type tt = [A of (string * int) | B];
which makes the difference much more clear.
Yours,
- Johan Granström
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
prev parent reply other threads:[~2002-03-11 23:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-11 22:33 Jeff Polakow
2002-03-11 23:35 ` Johan Georg Granström [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='018d01c1c955$79451c20$e08c72d5@invariant.se' \
--to=georg.g@home.se \
--cc=caml-list@inria.fr \
--cc=jpolakow@gnp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox