arity of type constructors

Christian Lindig
 David Monniaux
 Michel Quercia
[
Home
]
[ Index:
by date

by threads
]
[ Message by date: previous  next ] [ Message in thread: previous  next ] [ Thread: previous  next ]
[ Message by date: previous  next ] [ Message in thread: previous  next ] [ Thread: previous  next ]
Date:   (:) 
From:  Michel Quercia <quercia@c...> 
Subject:  Re: arity of type constructors 
Christian Lindig wrote: > > Objective Caml version 1.05 > # type t = T of int * int;; > type t =  T of int * int > # let x = (3,4);; > val x : int * int = 3, 4 > # T x;; > The constructor T expects 2 argument(s), but is here applied > to 1 argument(s) > # T (3,4);; >  : t = T (3, 4) > > Applying T to x does not work, but applying it to (3,4) does. Why is > the pair (3,4) counted as 2 arguments? > here is the trick : Objective Caml version 1.05 # type t = T of int * int;; type t =  T of int * int # T(3,4);;  : t = T (3, 4) # let x = (3,4) in T(x);; The constructor T expects 2 argument(s), but is here applied to 1 argument(s) # type u = U of (int * int);; type u =  U of (int * int) # let x = (3,4) in U(x);;  : u = U (3, 4) #  Michel Quercia Lycee Carnot 16 bd Thiers 21000 Dijon mailto:quercia@cal.enst.fr