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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Carette <carette@m...>
Subject: Not a variant??
The function f1 below works fine -- so type d is seen to be a variant type.
However, f2 does not compile because type c is *not* a variant type. 

However, if one looks at O'Caml's output for type c, it visually looks 
like a variant, while that of d does not.  This is highly confusing.

This looks like a bug to me -- both c and d should be recognized as 
variant types.

Jacques

type a = [`A ]
type b = [`B ]
type 'a c = 'a
    constraint 'a = [< a | b]
    ;;
type 'a d = 'a
    constraint 'a = b
    ;;

let f1 = function
    | #d -> true
    | _  -> false

let f2 = function
    | #c -> true
    | _  -> false
;;