Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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? 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  Archives: