caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Unexpected '_a problem
@ 2006-08-01 20:47 Chris King
  2006-08-01 21:20 ` [Caml-list] " Andreas Rossberg
  0 siblings, 1 reply; 9+ messages in thread
From: Chris King @ 2006-08-01 20:47 UTC (permalink / raw)
  To: O'Caml Mailing List

Given this code:

# let create_foo () = object method foo (_: 'a) = () end;;
val create_foo : unit -> < foo : 'a -> unit > = <fun>
# let a = create_foo ();;
val a : < bar : '_a -> unit > = <obj>

the compiler determines a is monomorphic, since 'a is in a
contravariant position.  But why, when 'a is placed in a covariant
position:

# let create_bar () = object method bar (_: 'a) = () end;;
val create_bar : unit -> < bar : ('a -> unit) -> unit > = <fun>
# let b = create_bar ();;
val b : < bar : ('_a -> unit) -> unit > = <obj>

does the compiler restrict b to be monomorphic?  If I wrap everything
up in a module and abstract the type returned by create_bar (),
create_bar () works as expected and returns a polymorphic value.

Thanks,
Chris King


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

end of thread, other threads:[~2006-08-04 14:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-01 20:47 Unexpected '_a problem Chris King
2006-08-01 21:20 ` [Caml-list] " Andreas Rossberg
2006-08-01 22:09   ` Remi Vanicat
2006-08-02  7:00     ` Alain Frisch
2006-08-02 17:57       ` Chris King
2006-08-04  2:42         ` Jacques Garrigue
2006-08-04 14:18           ` Chris King
2006-08-02  7:03     ` Christophe Dehlinger
2006-08-02  8:07       ` Andreas Rossberg

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).