Version française
Home     About     Download     Resources     Contact us    
Browse thread
polymorphic variant oddity
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John Prevost <jmp@a...>
Subject: Re: polymorphic variant oddity
>>>>> "ja" == Julian Assange <proff@iq.org> writes:

  ja> Unbound value x
  ja> # let `F x = 1;;
  ja> This expression has type int but is here used with type [< `F of 'a | ..]
  ja> # let `F x = `F 1;;
  ja> val x : int = 1
  ja> # `F 4;;
  ja> - : [> `F of int] = `F 4

  ja> What exactly is the meaning this?

Looks like normal pattern matching to me:


# let Some x = x;;
Unbound value x
# let Some x = 1;;
This expression has type int but is here used with type 'a option
# let Some x = Some 1;;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
None
val x : int = 1
# Some 4;; 
- : int option = Some 4

What did you expect to happen?

John.