caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Rodolphe Lepigre <rodolphe.lepigre@univ-savoie.fr>
To: Malcolm Matalka <mmatalka@gmail.com>
Cc: Christopher Zimmermann <christopher@gmerlin.de>, caml-list@inria.fr
Subject: Re: [Caml-list] 'b t doesn't equal '_b t?
Date: Mon, 25 Jul 2016 11:36:24 +0200	[thread overview]
Message-ID: <20160725093624.GC443@HPArchRod.localdomain> (raw)
In-Reply-To: <8660ru83s2.fsf@gmail.com>

On 25/07/2016 09:29, Malcolm Matalka wrote:
> Christopher Zimmermann <christopher@gmerlin.de> writes:
> 
> > '_b t is just not polymorphic. It just means the compiler could not yet
> > figure out the monomorphic type of '_b. It will be bound to a
> > monomorphic type later on.
> 
> How does one track down and why this is happening?  I tried adding some
> typo annotations, but no luck.  Maybe I didn't add them in the right
> place or I added the wrong annotations?
> 
> Any tips for handling this situation?

Just use an explicit quantification on your definition of bind by doing
something like:

  let bind : type a b. a t -> (a -> b t) -> b t = fun x y -> ...

There are two main reasons why the right polymorphic type is not infered:
 1) value restriction,
 2) you are using polymorphic recursion.

Cheers,

Rodolphe

-- 
Rodolphe Lepigre
LAMA, Université Savoie Mont Blanc, FRANCE
http://lama.univ-smb.fr/~lepigre/

> 
> >
> >
> > On 2016-07-24 Malcolm Matalka <mmatalka@gmail.com> wrote:
> >> I have the following error and I don't understand what the compiler is
> >> trying to tell me.  Any hints?
> >> 
> >> Error: The implementation abb_fut.ml
> >>        does not match the interface abb_fut.cmi:
> >>        Values do not match:
> >>          val bind : 'a t -> ('a -> '_b t) -> '_b t
> >>        is not included in
> >>          val bind : 'a t -> ('a -> 'b t) -> 'b t
> >>        File "abb_fut.ml", line 118, characters 4-8: Actual declaration
> >> 

  reply	other threads:[~2016-07-25  9:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-24 16:48 Malcolm Matalka
2016-07-24 19:17 ` Christopher Zimmermann
2016-07-25  9:29   ` Malcolm Matalka
2016-07-25  9:36     ` Rodolphe Lepigre [this message]
2016-08-08 10:06     ` Goswin von Brederlow
2016-08-08 14:35       ` Malcolm Matalka

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=20160725093624.GC443@HPArchRod.localdomain \
    --to=rodolphe.lepigre@univ-savoie.fr \
    --cc=caml-list@inria.fr \
    --cc=christopher@gmerlin.de \
    --cc=mmatalka@gmail.com \
    /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).