Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] mystified by typing of optional arguments
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Eric C. Cooper <ecc@c...>
Subject: Re: [Caml-list] mystified by typing of optional arguments
On Thu, Apr 03, 2003 at 04:50:44PM +0200, Francois Rouaix wrote:
> The following example mystifies me
> 
> let f ?opt x =
>   match opt with
>   | None -> x
>   | Some dx -> x + dx
> 
> let g x = x + 1
> 
> let h1 = function
>   | 0 -> [g]
>   | _ -> [f; g]
> 
> 
> let h2 = function
>   | _ -> [f; g]
> 
> 
> h1 is typable but not h2.
> Why is that ?

Even simpler: [g; f] type-checks, but [f; g] does not.

-- 
Eric C. Cooper          e c c @ c m u . e d u

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners