From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] strange behavior with record type definition
Date: Fri, 11 Nov 2005 23:52:39 +0000 [thread overview]
Message-ID: <200511112352.39853.jon@ffconsultancy.com> (raw)
In-Reply-To: <43752259.80800@aist.enst.fr>
On Friday 11 November 2005 22:59, Florent wrote:
> Hi, I have defined two distinct record's types with a field's name in
> common. But when I try to define a function that uses the first of the
> types, the compiler gives me a type error.
> How can I use my first type in a function ??
>
> This is what I did:
>
> # type t0 = { i : int ; s : string };;
> type t0 = { i : int; s : string; }
> # type t1 = { i : int ; f : float };;
> type t1 = { i : int; f : float; }
> # let f (x:t0) = match x with {i= a; s= b} -> b;;
> Characters 28-40:
> let f (x:t0) = match x with {i= a; s= b} -> b;;
> ^^^^^^^^^^^^
> The record field label s belongs to the type t0
> but is here mixed with labels of type t1
Either use different field names, e.g.:
type t0 = { i0 : int ; s0 : string }
type t1 = { i1 : int ; f1 : float }
or put them in separate modules.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
next prev parent reply other threads:[~2005-11-11 23:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-11 22:59 Florent
2005-11-11 23:52 ` Jon Harrop [this message]
2005-11-12 0:15 ` [Caml-list] " Michael Wohlwend
2005-11-12 0:20 ` Martin Jambon
2005-11-12 10:58 ` Florent
2005-11-12 12:12 ` skaller
2005-11-12 12:20 ` Nicolas Cannasse
2005-11-12 12:51 ` skaller
2005-11-12 14:15 ` Michael Wohlwend
2005-11-12 14:45 ` skaller
2005-11-12 15:26 ` Christophe TROESTLER
2005-11-12 14:23 ` Florent
2005-11-12 15:32 ` Christophe TROESTLER
2005-11-12 16:50 ` Florian Weimer
2005-11-13 0:12 ` Jacques Garrigue
2005-11-13 12:50 ` Florent
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=200511112352.39853.jon@ffconsultancy.com \
--to=jon@ffconsultancy.com \
--cc=caml-list@yquem.inria.fr \
/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