caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] 'b t doesn't equal '_b t?
@ 2016-07-24 16:48 Malcolm Matalka
  2016-07-24 19:17 ` Christopher Zimmermann
  0 siblings, 1 reply; 6+ messages in thread
From: Malcolm Matalka @ 2016-07-24 16:48 UTC (permalink / raw)
  To: caml-list

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

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

* Re: [Caml-list] 'b t doesn't equal '_b t?
  2016-07-24 16:48 [Caml-list] 'b t doesn't equal '_b t? Malcolm Matalka
@ 2016-07-24 19:17 ` Christopher Zimmermann
  2016-07-25  9:29   ` Malcolm Matalka
  0 siblings, 1 reply; 6+ messages in thread
From: Christopher Zimmermann @ 2016-07-24 19:17 UTC (permalink / raw)
  To: caml-list; +Cc: Malcolm Matalka

'_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.


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
> 



-- 
http://gmerlin.de
OpenPGP: http://gmerlin.de/christopher.pub
2779 7F73 44FD 0736 B67A  C410 69EC 7922 34B4 2566

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

* Re: [Caml-list] 'b t doesn't equal '_b t?
  2016-07-24 19:17 ` Christopher Zimmermann
@ 2016-07-25  9:29   ` Malcolm Matalka
  2016-07-25  9:36     ` Rodolphe Lepigre
  2016-08-08 10:06     ` Goswin von Brederlow
  0 siblings, 2 replies; 6+ messages in thread
From: Malcolm Matalka @ 2016-07-25  9:29 UTC (permalink / raw)
  To: Christopher Zimmermann; +Cc: caml-list

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?

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

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

* Re: [Caml-list] 'b t doesn't equal '_b t?
  2016-07-25  9:29   ` Malcolm Matalka
@ 2016-07-25  9:36     ` Rodolphe Lepigre
  2016-08-08 10:06     ` Goswin von Brederlow
  1 sibling, 0 replies; 6+ messages in thread
From: Rodolphe Lepigre @ 2016-07-25  9:36 UTC (permalink / raw)
  To: Malcolm Matalka; +Cc: Christopher Zimmermann, caml-list

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

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

* Re: [Caml-list] 'b t doesn't equal '_b t?
  2016-07-25  9:29   ` Malcolm Matalka
  2016-07-25  9:36     ` Rodolphe Lepigre
@ 2016-08-08 10:06     ` Goswin von Brederlow
  2016-08-08 14:35       ` Malcolm Matalka
  1 sibling, 1 reply; 6+ messages in thread
From: Goswin von Brederlow @ 2016-08-08 10:06 UTC (permalink / raw)
  To: Malcolm Matalka; +Cc: Christopher Zimmermann, caml-list

On Mon, Jul 25, 2016 at 09:29:01AM +0000, 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?
> 
> >
> >
> > 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
> >> 

You can not annotate a function to be more polymorphic, only less.
It's basically just a lower limit. So if you annotate a type as "'a t"
that means the type must be some t, but 'a can still be infered to be
not prolymorphic. This makes it hard to find cases where the infering
gets too specific for your taste.

MfG
	Goswin

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

* Re: [Caml-list] 'b t doesn't equal '_b t?
  2016-08-08 10:06     ` Goswin von Brederlow
@ 2016-08-08 14:35       ` Malcolm Matalka
  0 siblings, 0 replies; 6+ messages in thread
From: Malcolm Matalka @ 2016-08-08 14:35 UTC (permalink / raw)
  To: Goswin von Brederlow; +Cc: Christopher Zimmermann, caml-list

Goswin von Brederlow <goswin-v-b@web.de> writes:

> On Mon, Jul 25, 2016 at 09:29:01AM +0000, 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?
>> 
>> >
>> >
>> > 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
>> >> 
>
> You can not annotate a function to be more polymorphic, only less.
> It's basically just a lower limit. So if you annotate a type as "'a t"
> that means the type must be some t, but 'a can still be infered to be
> not prolymorphic. This makes it hard to find cases where the infering
> gets too specific for your taste.

I managed to find it by adding some polymorphic type annotations and
then the compiler directed me to the offending line that violated that
annotation.

>
> MfG
> 	Goswin

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

end of thread, other threads:[~2016-08-08 14:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-24 16:48 [Caml-list] 'b t doesn't equal '_b t? Malcolm Matalka
2016-07-24 19:17 ` Christopher Zimmermann
2016-07-25  9:29   ` Malcolm Matalka
2016-07-25  9:36     ` Rodolphe Lepigre
2016-08-08 10:06     ` Goswin von Brederlow
2016-08-08 14:35       ` Malcolm Matalka

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