caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* signature and 'a generic types
@ 2005-06-20 15:20 Damien Bobillot
  2005-06-20 15:59 ` [Caml-list] " Virgile Prevosto
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Damien Bobillot @ 2005-06-20 15:20 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 983 bytes --]

Hello,

Look at the following code :

     module Module : (sig val func : 'a -> 'b end) =
     struct let func a = a end

Here Module.func's type is 'a -> 'a. According to me 'a -> 'a is a  
subtype of 'a -> 'b, it's 'a -> 'b with 'a = 'b. Nevertheless ocamlc  
give the following error :

     Values do not match:
       val func : 'a -> 'a
     is not included in
       val func : 'a -> 'b

Why ?

I also try to use the reverse match :

     module Module : (sig val func : 'a -> 'a end) = struct
         let l = ref []
         let func a = List.assoc a !l
     end

Where Module.func is of type 'a -> 'b. Ocamlc also give me an error,  
but I completely understand it here : 'a -> 'b is really not a  
subtype of 'a -> 'a.

In this case I also don't understand why neither " 'a -> 'b is  
included in 'a -> 'a " nor " 'a -> 'a is included in 'a -> 'b " are  
true. To my mind, one should be true.

Is it a caml limitation/bug, or am I wrong somewhere ?

-- 
Damien Bobillot


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2375 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-06-20 22:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-20 15:20 signature and 'a generic types Damien Bobillot
2005-06-20 15:59 ` [Caml-list] " Virgile Prevosto
2005-06-20 16:06 ` Stephane Glondu
2005-06-20 16:19 ` Marcin 'Qrczak' Kowalczyk
2005-06-20 22:31 ` Michael Alexander Hamburg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).