Version française
Home     About     Download     Resources     Contact us    
Browse thread
List.cons and "::"
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] List.cons and "::"
On Tuesday 17 July 2007 21:02:29 Sam Steingold wrote:
> Why is :: a syntax, not an infix version of List.cons

List.cons would be a function whereas :: is a type constructor for the 'a list 
type:

# type 'a list = :: of 'a * 'a list;;
type 'a list = :: of 'a * 'a list
# let rec list = 1 :: list;;
val list : int list =
  :: (1, ...

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists/?e