caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Malcolm Matalka <mmatalka@gmail.com>
To: caml-list@inria.fr
Subject: [Caml-list] Type variables and polymorphic variants
Date: Tue, 12 Mar 2013 17:57:50 -0400	[thread overview]
Message-ID: <87ip4wffhd.fsf@li195-236.members.linode.com> (raw)

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

             reply	other threads:[~2013-03-12 21:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-12 21:57 Malcolm Matalka [this message]
2013-03-13  2:06 ` Jacques Garrigue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ip4wffhd.fsf@li195-236.members.linode.com \
    --to=mmatalka@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).