English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: [Caml-list] variant with tuple arg in pattern match?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-04-10 (12:34)
From: Michel Mauny <Michel.Mauny@i...>
Subject: Re: [Caml-list] variant with tuple arg in pattern match?
reig@dcs.gla.ac.uk wrote/écrivait (Apr 10 2001, 01:10PM +0100):

> In fact, the syntax for the type definition could be like in haskell:
> use juxtaposition.
> type 'a t = Curried  : ('a t) ('a t)
> 	  | Function : 'a t -> 'a t

In this case, there is an ambiguity between curryfication and type
constructors application.


  type t = C : int bool

is C of type int -> bool -> t, or is bool a unary type constructor,
with int as argument. Compare with

  type t = C : int list

for instance. Parsing would need typing information, here.

Haskell avoids this in using the same notation (juxtaposition) all the
way long. That is, the examples above would be written as

  type t = C int bool

  type t = C (int list)

and made unambiguous using parens. Using  a `:' right after the data
constructor is (to me) less clear than the Haskell notation. Maybe
because of type constraints and module interfaces.

To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr