caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Type variables and polymorphic variants
@ 2013-03-12 21:57 Malcolm Matalka
  2013-03-13  2:06 ` Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: Malcolm Matalka @ 2013-03-12 21:57 UTC (permalink / raw)
  To: caml-list

Hello!  I use polymorphic variants extensively in my code for getting
the compiler to make sure I handle errors.  However, I'm trying to write
the following function which is proving hard, the errors are below.

I have come across similar issues before and it is related to the type
variable. I believe the problem is the [> in error because it can't know
if I return a polymorphic variant in this function if that is the error
or not.

What is the cleanest way to write this function?

val with_conn :
  host:string ->
  port:int ->
  (unit -> ('a, [> error ]) Deferred.Result.t) ->
  ('a, [> error ]) Deferred.Result.t


Error: The implementation conn.ml does not match the interface conn.cmi:
       Values do not match:
         val with_conn :
           host:string ->
           port:int ->
           (unit ->
            ('a, [> `Bad_conn ] as 'b) Core.Std._result
       Async_core.Deferred.t) ->
           ('a, 'b) Core.Std._result Async_core.Deferred.t
       is not included in
         val with_conn :
           host:string ->
           port:int ->
           (unit -> ('a, [> error ]) Async.Std.Deferred.Result.t) ->
           ('a, [> error ]) Async.Std.Deferred.Result.t


Thanks!

/Malcolm

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

end of thread, other threads:[~2013-03-13  2:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-12 21:57 [Caml-list] Type variables and polymorphic variants Malcolm Matalka
2013-03-13  2:06 ` Jacques Garrigue

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