caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Types look compatible, but they aren't?
@ 2013-04-13  6:50 Anthony Tavener
  2013-04-13  6:56 ` Kakadu
  0 siblings, 1 reply; 7+ messages in thread
From: Anthony Tavener @ 2013-04-13  6:50 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 875 bytes --]

File "virtue.ml", line 462, characters 12-24:
Error: This expression has type
         int * ((int * int -> int * int) list -> exn) *
         (exn -> (int * int -> int * int) list)
       but an expression was expected of type
         int * ((< .. > as 'a) list -> exn) * (exn -> 'a list)

The code in question:

  (fun id ->
    let m = Modifier.attach id in
      [ m Cast.total'k (fun (v,b) -> (v, max 1 (b-3)))     (* <-- line 462
*)
      ; m Lab.total'k (fun (v,b) -> (v, max 1 (b-3))) ])

For reference, the signature of Modifier.attach:
  Db.key -> int * ('a list -> exn) * (exn -> 'a list) -> 'a ->
Modifier.deleter

OCaml version is 4.00.0 -- I know I should upgrade. Keep meaning to, I
guess I will if I wake up and there's no helpful soul explaining what could
be wrong here. :)

Thank-you for any help. My eyes are starting to bug-out looking at this.

 -Tony

[-- Attachment #2: Type: text/html, Size: 1391 bytes --]

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

* Re: [Caml-list] Types look compatible, but they aren't?
  2013-04-13  6:50 [Caml-list] Types look compatible, but they aren't? Anthony Tavener
@ 2013-04-13  6:56 ` Kakadu
  2013-04-13  7:33   ` Gabriel Scherer
  0 siblings, 1 reply; 7+ messages in thread
From: Kakadu @ 2013-04-13  6:56 UTC (permalink / raw)
  To: Anthony Tavener; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 1108 bytes --]

Maybe function type (int * int -> int * int) is incompatible with object
type <..>?

Kakadu


On Sat, Apr 13, 2013 at 10:50 AM, Anthony Tavener <anthony.tavener@gmail.com
> wrote:

> File "virtue.ml", line 462, characters 12-24:
> Error: This expression has type
>          int * ((int * int -> int * int) list -> exn) *
>          (exn -> (int * int -> int * int) list)
>        but an expression was expected of type
>          int * ((< .. > as 'a) list -> exn) * (exn -> 'a list)
>
> The code in question:
>
>   (fun id ->
>     let m = Modifier.attach id in
>       [ m Cast.total'k (fun (v,b) -> (v, max 1 (b-3)))     (* <-- line
> 462 *)
>       ; m Lab.total'k (fun (v,b) -> (v, max 1 (b-3))) ])
>
> For reference, the signature of Modifier.attach:
>   Db.key -> int * ('a list -> exn) * (exn -> 'a list) -> 'a ->
> Modifier.deleter
>
> OCaml version is 4.00.0 -- I know I should upgrade. Keep meaning to, I
> guess I will if I wake up and there's no helpful soul explaining what could
> be wrong here. :)
>
> Thank-you for any help. My eyes are starting to bug-out looking at this.
>
>  -Tony
>
>
>

[-- Attachment #2: Type: text/html, Size: 1896 bytes --]

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

* Re: [Caml-list] Types look compatible, but they aren't?
  2013-04-13  6:56 ` Kakadu
@ 2013-04-13  7:33   ` Gabriel Scherer
  2013-04-13 16:07     ` Anthony Tavener
  0 siblings, 1 reply; 7+ messages in thread
From: Gabriel Scherer @ 2013-04-13  7:33 UTC (permalink / raw)
  To: Kakadu; +Cc: Anthony Tavener, caml-list

This looks like a value restriction issue with

  let m = Modifier.attach id

  "A function obtained through partial application is not polymorphic enough"
  http://caml.inria.fr/resources/doc/faq/core.en.html#eta-expansion

If this is indeed the source of your error, you can regain
type-checking by using instead

  let m total = Modifier.attach id total

Note that this may change the semantics of your code if
(Modifier.attach id) does a side-effect before getting its next
parameter: if would have been effected only once with your previous
definition, and will be effected at each call of 'm' with the new
definition.

On Sat, Apr 13, 2013 at 8:56 AM, Kakadu <kakadu.hafanana@gmail.com> wrote:
> Maybe function type (int * int -> int * int) is incompatible with object
> type <..>?
>
> Kakadu
>
>
> On Sat, Apr 13, 2013 at 10:50 AM, Anthony Tavener
> <anthony.tavener@gmail.com> wrote:
>>
>> File "virtue.ml", line 462, characters 12-24:
>> Error: This expression has type
>>          int * ((int * int -> int * int) list -> exn) *
>>          (exn -> (int * int -> int * int) list)
>>        but an expression was expected of type
>>          int * ((< .. > as 'a) list -> exn) * (exn -> 'a list)
>>
>> The code in question:
>>
>>   (fun id ->
>>     let m = Modifier.attach id in
>>       [ m Cast.total'k (fun (v,b) -> (v, max 1 (b-3)))     (* <-- line 462
>> *)
>>       ; m Lab.total'k (fun (v,b) -> (v, max 1 (b-3))) ])
>>
>> For reference, the signature of Modifier.attach:
>>   Db.key -> int * ('a list -> exn) * (exn -> 'a list) -> 'a ->
>> Modifier.deleter
>>
>> OCaml version is 4.00.0 -- I know I should upgrade. Keep meaning to, I
>> guess I will if I wake up and there's no helpful soul explaining what
>> could
>> be wrong here. :)
>>
>> Thank-you for any help. My eyes are starting to bug-out looking at this.
>>
>>  -Tony
>>
>>
>

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

* Re: [Caml-list] Types look compatible, but they aren't?
  2013-04-13  7:33   ` Gabriel Scherer
@ 2013-04-13 16:07     ` Anthony Tavener
  2013-04-13 16:15       ` Anthony Tavener
  0 siblings, 1 reply; 7+ messages in thread
From: Anthony Tavener @ 2013-04-13 16:07 UTC (permalink / raw)
  To: Gabriel Scherer; +Cc: Kakadu, caml-list

[-- Attachment #1: Type: text/plain, Size: 3459 bytes --]

Ohhh... that is interesting. (TL;DR: problem solved, and it was from
inappropriate Oo.id use.)

Modifier.attach is actually implemented as a function of one argument which
does some stuff,
returning a function of two arguments, to avoid redundant lookups in the
case of multiple "attach"
to the same "id".

When I remove the let m = ... and just inline "Modifer.attach id ..." the
type of Modifier.attach changes to:

  Db.key -> int * (((< _.. > as 'a) list -> exn) * (exn -> 'a list) -> 'a
-> Modifier.deleter

So, 'a becomes: (< _.. > as 'a) -- I get some monomorphic... object?

As I wrote this I had an idea and found the problem:

  ...
  (* return (tbl -> unit) function which deletes this specific function *)
  let del_id = Oo.id fn in
  (fun tbl ->
    let lst = List.filter (fun e -> Oo.id e <> del_id) (fn_list tbl) in
    Hashtbl.replace tbl tag (inj lst))


Here, "fn" is the provided function, and I want an easy way to remove such
functions uniquely from the
mess of Hashtbl, universal embedding, and list. I tried a trick I once read
Alain suggest for getting a
unique id using the object module... and I guess that brought in this <..>
thing I was unfamiliar with. :)
Instead of Oo.id I'm using Hashtbl.hash now, which is normally what I'd
do... not sure why I
half-remembered some trick with Oo.id.

Thank-you for looking at this, both of you. It helped me dig in the right
direction!


On Sat, Apr 13, 2013 at 1:33 AM, Gabriel Scherer
<gabriel.scherer@gmail.com>wrote:

> This looks like a value restriction issue with
>
>   let m = Modifier.attach id
>
>   "A function obtained through partial application is not polymorphic
> enough"
>   http://caml.inria.fr/resources/doc/faq/core.en.html#eta-expansion
>
> If this is indeed the source of your error, you can regain
> type-checking by using instead
>
>   let m total = Modifier.attach id total
>
> Note that this may change the semantics of your code if
> (Modifier.attach id) does a side-effect before getting its next
> parameter: if would have been effected only once with your previous
> definition, and will be effected at each call of 'm' with the new
> definition.
>
> On Sat, Apr 13, 2013 at 8:56 AM, Kakadu <kakadu.hafanana@gmail.com> wrote:
> > Maybe function type (int * int -> int * int) is incompatible with object
> > type <..>?
> >
> > Kakadu
> >
> >
> > On Sat, Apr 13, 2013 at 10:50 AM, Anthony Tavener
> > <anthony.tavener@gmail.com> wrote:
> >>
> >> File "virtue.ml", line 462, characters 12-24:
> >> Error: This expression has type
> >>          int * ((int * int -> int * int) list -> exn) *
> >>          (exn -> (int * int -> int * int) list)
> >>        but an expression was expected of type
> >>          int * ((< .. > as 'a) list -> exn) * (exn -> 'a list)
> >>
> >> The code in question:
> >>
> >>   (fun id ->
> >>     let m = Modifier.attach id in
> >>       [ m Cast.total'k (fun (v,b) -> (v, max 1 (b-3)))     (* <-- line
> 462
> >> *)
> >>       ; m Lab.total'k (fun (v,b) -> (v, max 1 (b-3))) ])
> >>
> >> For reference, the signature of Modifier.attach:
> >>   Db.key -> int * ('a list -> exn) * (exn -> 'a list) -> 'a ->
> >> Modifier.deleter
> >>
> >> OCaml version is 4.00.0 -- I know I should upgrade. Keep meaning to, I
> >> guess I will if I wake up and there's no helpful soul explaining what
> >> could
> >> be wrong here. :)
> >>
> >> Thank-you for any help. My eyes are starting to bug-out looking at this.
> >>
> >>  -Tony
> >>
> >>
> >
>

[-- Attachment #2: Type: text/html, Size: 5182 bytes --]

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

* Re: [Caml-list] Types look compatible, but they aren't?
  2013-04-13 16:07     ` Anthony Tavener
@ 2013-04-13 16:15       ` Anthony Tavener
  2013-04-13 17:14         ` Gabriel Scherer
  0 siblings, 1 reply; 7+ messages in thread
From: Anthony Tavener @ 2013-04-13 16:15 UTC (permalink / raw)
  To: Gabriel Scherer; +Cc: Kakadu, caml-list

[-- Attachment #1: Type: text/plain, Size: 4087 bytes --]

I forgot to note, that the interesting thing was how the type inferred for
Modifier.attach when it had
one argument applied did not show the < _.. > monomorphic object
constraint. Modifier.attach
is actually a: fun id -> (key -> fn -> deleter), rather than a
straightforward three-argument function. Once
the (key -> fn -> deleter) function would come into play, the "object" was
revealed.


On Sat, Apr 13, 2013 at 10:07 AM, Anthony Tavener <anthony.tavener@gmail.com
> wrote:

> Ohhh... that is interesting. (TL;DR: problem solved, and it was from
> inappropriate Oo.id use.)
>
> Modifier.attach is actually implemented as a function of one argument
> which does some stuff,
> returning a function of two arguments, to avoid redundant lookups in the
> case of multiple "attach"
> to the same "id".
>
> When I remove the let m = ... and just inline "Modifer.attach id ..." the
> type of Modifier.attach changes to:
>
>   Db.key -> int * (((< _.. > as 'a) list -> exn) * (exn -> 'a list) -> 'a
> -> Modifier.deleter
>
> So, 'a becomes: (< _.. > as 'a) -- I get some monomorphic... object?
>
> As I wrote this I had an idea and found the problem:
>
>   ...
>   (* return (tbl -> unit) function which deletes this specific function *)
>   let del_id = Oo.id fn in
>   (fun tbl ->
>     let lst = List.filter (fun e -> Oo.id e <> del_id) (fn_list tbl) in
>     Hashtbl.replace tbl tag (inj lst))
>
>
> Here, "fn" is the provided function, and I want an easy way to remove such
> functions uniquely from the
> mess of Hashtbl, universal embedding, and list. I tried a trick I once
> read Alain suggest for getting a
> unique id using the object module... and I guess that brought in this <..>
> thing I was unfamiliar with. :)
> Instead of Oo.id I'm using Hashtbl.hash now, which is normally what I'd
> do... not sure why I
> half-remembered some trick with Oo.id.
>
> Thank-you for looking at this, both of you. It helped me dig in the right
> direction!
>
>
> On Sat, Apr 13, 2013 at 1:33 AM, Gabriel Scherer <
> gabriel.scherer@gmail.com> wrote:
>
>> This looks like a value restriction issue with
>>
>>   let m = Modifier.attach id
>>
>>   "A function obtained through partial application is not polymorphic
>> enough"
>>   http://caml.inria.fr/resources/doc/faq/core.en.html#eta-expansion
>>
>> If this is indeed the source of your error, you can regain
>> type-checking by using instead
>>
>>   let m total = Modifier.attach id total
>>
>> Note that this may change the semantics of your code if
>> (Modifier.attach id) does a side-effect before getting its next
>> parameter: if would have been effected only once with your previous
>> definition, and will be effected at each call of 'm' with the new
>> definition.
>>
>> On Sat, Apr 13, 2013 at 8:56 AM, Kakadu <kakadu.hafanana@gmail.com>
>> wrote:
>> > Maybe function type (int * int -> int * int) is incompatible with object
>> > type <..>?
>> >
>> > Kakadu
>> >
>> >
>> > On Sat, Apr 13, 2013 at 10:50 AM, Anthony Tavener
>> > <anthony.tavener@gmail.com> wrote:
>> >>
>> >> File "virtue.ml", line 462, characters 12-24:
>> >> Error: This expression has type
>> >>          int * ((int * int -> int * int) list -> exn) *
>> >>          (exn -> (int * int -> int * int) list)
>> >>        but an expression was expected of type
>> >>          int * ((< .. > as 'a) list -> exn) * (exn -> 'a list)
>> >>
>> >> The code in question:
>> >>
>> >>   (fun id ->
>> >>     let m = Modifier.attach id in
>> >>       [ m Cast.total'k (fun (v,b) -> (v, max 1 (b-3)))     (* <-- line
>> 462
>> >> *)
>> >>       ; m Lab.total'k (fun (v,b) -> (v, max 1 (b-3))) ])
>> >>
>> >> For reference, the signature of Modifier.attach:
>> >>   Db.key -> int * ('a list -> exn) * (exn -> 'a list) -> 'a ->
>> >> Modifier.deleter
>> >>
>> >> OCaml version is 4.00.0 -- I know I should upgrade. Keep meaning to, I
>> >> guess I will if I wake up and there's no helpful soul explaining what
>> >> could
>> >> be wrong here. :)
>> >>
>> >> Thank-you for any help. My eyes are starting to bug-out looking at
>> this.
>> >>
>> >>  -Tony
>> >>
>> >>
>> >
>>
>
>

[-- Attachment #2: Type: text/html, Size: 5975 bytes --]

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

* Re: [Caml-list] Types look compatible, but they aren't?
  2013-04-13 16:15       ` Anthony Tavener
@ 2013-04-13 17:14         ` Gabriel Scherer
  2013-04-13 17:25           ` Anthony Tavener
  0 siblings, 1 reply; 7+ messages in thread
From: Gabriel Scherer @ 2013-04-13 17:14 UTC (permalink / raw)
  To: Anthony Tavener; +Cc: Kakadu, caml-list

> So, 'a becomes: (< _.. > as 'a) -- I get some monomorphic... object?

Just a small thing, (< .. > as 'a) is not monomorphic, it is still a
polymorphic type, that may be instantiated with any object type. It is
"less polymorphic" than 'a (can be instantiated with anything).

On Sat, Apr 13, 2013 at 6:15 PM, Anthony Tavener
<anthony.tavener@gmail.com> wrote:
> I forgot to note, that the interesting thing was how the type inferred for
> Modifier.attach when it had
> one argument applied did not show the < _.. > monomorphic object constraint.
> Modifier.attach
> is actually a: fun id -> (key -> fn -> deleter), rather than a
> straightforward three-argument function. Once
> the (key -> fn -> deleter) function would come into play, the "object" was
> revealed.
>
>
> On Sat, Apr 13, 2013 at 10:07 AM, Anthony Tavener
> <anthony.tavener@gmail.com> wrote:
>>
>> Ohhh... that is interesting. (TL;DR: problem solved, and it was from
>> inappropriate Oo.id use.)
>>
>> Modifier.attach is actually implemented as a function of one argument
>> which does some stuff,
>> returning a function of two arguments, to avoid redundant lookups in the
>> case of multiple "attach"
>> to the same "id".
>>
>> When I remove the let m = ... and just inline "Modifer.attach id ..." the
>> type of Modifier.attach changes to:
>>
>>   Db.key -> int * (((< _.. > as 'a) list -> exn) * (exn -> 'a list) -> 'a
>> -> Modifier.deleter
>>
>> So, 'a becomes: (< _.. > as 'a) -- I get some monomorphic... object?
>>
>> As I wrote this I had an idea and found the problem:
>>
>>   ...
>>   (* return (tbl -> unit) function which deletes this specific function *)
>>   let del_id = Oo.id fn in
>>   (fun tbl ->
>>     let lst = List.filter (fun e -> Oo.id e <> del_id) (fn_list tbl) in
>>     Hashtbl.replace tbl tag (inj lst))
>>
>>
>> Here, "fn" is the provided function, and I want an easy way to remove such
>> functions uniquely from the
>> mess of Hashtbl, universal embedding, and list. I tried a trick I once
>> read Alain suggest for getting a
>> unique id using the object module... and I guess that brought in this <..>
>> thing I was unfamiliar with. :)
>> Instead of Oo.id I'm using Hashtbl.hash now, which is normally what I'd
>> do... not sure why I
>> half-remembered some trick with Oo.id.
>>
>> Thank-you for looking at this, both of you. It helped me dig in the right
>> direction!
>>
>>
>> On Sat, Apr 13, 2013 at 1:33 AM, Gabriel Scherer
>> <gabriel.scherer@gmail.com> wrote:
>>>
>>> This looks like a value restriction issue with
>>>
>>>   let m = Modifier.attach id
>>>
>>>   "A function obtained through partial application is not polymorphic
>>> enough"
>>>   http://caml.inria.fr/resources/doc/faq/core.en.html#eta-expansion
>>>
>>> If this is indeed the source of your error, you can regain
>>> type-checking by using instead
>>>
>>>   let m total = Modifier.attach id total
>>>
>>> Note that this may change the semantics of your code if
>>> (Modifier.attach id) does a side-effect before getting its next
>>> parameter: if would have been effected only once with your previous
>>> definition, and will be effected at each call of 'm' with the new
>>> definition.
>>>
>>> On Sat, Apr 13, 2013 at 8:56 AM, Kakadu <kakadu.hafanana@gmail.com>
>>> wrote:
>>> > Maybe function type (int * int -> int * int) is incompatible with
>>> > object
>>> > type <..>?
>>> >
>>> > Kakadu
>>> >
>>> >
>>> > On Sat, Apr 13, 2013 at 10:50 AM, Anthony Tavener
>>> > <anthony.tavener@gmail.com> wrote:
>>> >>
>>> >> File "virtue.ml", line 462, characters 12-24:
>>> >> Error: This expression has type
>>> >>          int * ((int * int -> int * int) list -> exn) *
>>> >>          (exn -> (int * int -> int * int) list)
>>> >>        but an expression was expected of type
>>> >>          int * ((< .. > as 'a) list -> exn) * (exn -> 'a list)
>>> >>
>>> >> The code in question:
>>> >>
>>> >>   (fun id ->
>>> >>     let m = Modifier.attach id in
>>> >>       [ m Cast.total'k (fun (v,b) -> (v, max 1 (b-3)))     (* <-- line
>>> >> 462
>>> >> *)
>>> >>       ; m Lab.total'k (fun (v,b) -> (v, max 1 (b-3))) ])
>>> >>
>>> >> For reference, the signature of Modifier.attach:
>>> >>   Db.key -> int * ('a list -> exn) * (exn -> 'a list) -> 'a ->
>>> >> Modifier.deleter
>>> >>
>>> >> OCaml version is 4.00.0 -- I know I should upgrade. Keep meaning to, I
>>> >> guess I will if I wake up and there's no helpful soul explaining what
>>> >> could
>>> >> be wrong here. :)
>>> >>
>>> >> Thank-you for any help. My eyes are starting to bug-out looking at
>>> >> this.
>>> >>
>>> >>  -Tony
>>> >>
>>> >>
>>> >
>>
>>
>

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

* Re: [Caml-list] Types look compatible, but they aren't?
  2013-04-13 17:14         ` Gabriel Scherer
@ 2013-04-13 17:25           ` Anthony Tavener
  0 siblings, 0 replies; 7+ messages in thread
From: Anthony Tavener @ 2013-04-13 17:25 UTC (permalink / raw)
  To: Gabriel Scherer; +Cc: Kakadu, caml-list

[-- Attachment #1: Type: text/plain, Size: 5357 bytes --]

In this instance it aquired a _ though, or does that have some other
meaning here?

I was getting < .. > at first, but when I called Modifer.attach with three
arguments the inference
changed to < _.. >.

As a side note, I didn't know what to make of < .. > until Kakadu mentioned
objects. I was thinking "what is that, some kind of abstract type"? That's
what I get for rarely using objects!


On Sat, Apr 13, 2013 at 11:14 AM, Gabriel Scherer <gabriel.scherer@gmail.com
> wrote:

> > So, 'a becomes: (< _.. > as 'a) -- I get some monomorphic... object?
>
> Just a small thing, (< .. > as 'a) is not monomorphic, it is still a
> polymorphic type, that may be instantiated with any object type. It is
> "less polymorphic" than 'a (can be instantiated with anything).
>
> On Sat, Apr 13, 2013 at 6:15 PM, Anthony Tavener
> <anthony.tavener@gmail.com> wrote:
> > I forgot to note, that the interesting thing was how the type inferred
> for
> > Modifier.attach when it had
> > one argument applied did not show the < _.. > monomorphic object
> constraint.
> > Modifier.attach
> > is actually a: fun id -> (key -> fn -> deleter), rather than a
> > straightforward three-argument function. Once
> > the (key -> fn -> deleter) function would come into play, the "object"
> was
> > revealed.
> >
> >
> > On Sat, Apr 13, 2013 at 10:07 AM, Anthony Tavener
> > <anthony.tavener@gmail.com> wrote:
> >>
> >> Ohhh... that is interesting. (TL;DR: problem solved, and it was from
> >> inappropriate Oo.id use.)
> >>
> >> Modifier.attach is actually implemented as a function of one argument
> >> which does some stuff,
> >> returning a function of two arguments, to avoid redundant lookups in the
> >> case of multiple "attach"
> >> to the same "id".
> >>
> >> When I remove the let m = ... and just inline "Modifer.attach id ..."
> the
> >> type of Modifier.attach changes to:
> >>
> >>   Db.key -> int * (((< _.. > as 'a) list -> exn) * (exn -> 'a list) ->
> 'a
> >> -> Modifier.deleter
> >>
> >> So, 'a becomes: (< _.. > as 'a) -- I get some monomorphic... object?
> >>
> >> As I wrote this I had an idea and found the problem:
> >>
> >>   ...
> >>   (* return (tbl -> unit) function which deletes this specific function
> *)
> >>   let del_id = Oo.id fn in
> >>   (fun tbl ->
> >>     let lst = List.filter (fun e -> Oo.id e <> del_id) (fn_list tbl) in
> >>     Hashtbl.replace tbl tag (inj lst))
> >>
> >>
> >> Here, "fn" is the provided function, and I want an easy way to remove
> such
> >> functions uniquely from the
> >> mess of Hashtbl, universal embedding, and list. I tried a trick I once
> >> read Alain suggest for getting a
> >> unique id using the object module... and I guess that brought in this
> <..>
> >> thing I was unfamiliar with. :)
> >> Instead of Oo.id I'm using Hashtbl.hash now, which is normally what I'd
> >> do... not sure why I
> >> half-remembered some trick with Oo.id.
> >>
> >> Thank-you for looking at this, both of you. It helped me dig in the
> right
> >> direction!
> >>
> >>
> >> On Sat, Apr 13, 2013 at 1:33 AM, Gabriel Scherer
> >> <gabriel.scherer@gmail.com> wrote:
> >>>
> >>> This looks like a value restriction issue with
> >>>
> >>>   let m = Modifier.attach id
> >>>
> >>>   "A function obtained through partial application is not polymorphic
> >>> enough"
> >>>   http://caml.inria.fr/resources/doc/faq/core.en.html#eta-expansion
> >>>
> >>> If this is indeed the source of your error, you can regain
> >>> type-checking by using instead
> >>>
> >>>   let m total = Modifier.attach id total
> >>>
> >>> Note that this may change the semantics of your code if
> >>> (Modifier.attach id) does a side-effect before getting its next
> >>> parameter: if would have been effected only once with your previous
> >>> definition, and will be effected at each call of 'm' with the new
> >>> definition.
> >>>
> >>> On Sat, Apr 13, 2013 at 8:56 AM, Kakadu <kakadu.hafanana@gmail.com>
> >>> wrote:
> >>> > Maybe function type (int * int -> int * int) is incompatible with
> >>> > object
> >>> > type <..>?
> >>> >
> >>> > Kakadu
> >>> >
> >>> >
> >>> > On Sat, Apr 13, 2013 at 10:50 AM, Anthony Tavener
> >>> > <anthony.tavener@gmail.com> wrote:
> >>> >>
> >>> >> File "virtue.ml", line 462, characters 12-24:
> >>> >> Error: This expression has type
> >>> >>          int * ((int * int -> int * int) list -> exn) *
> >>> >>          (exn -> (int * int -> int * int) list)
> >>> >>        but an expression was expected of type
> >>> >>          int * ((< .. > as 'a) list -> exn) * (exn -> 'a list)
> >>> >>
> >>> >> The code in question:
> >>> >>
> >>> >>   (fun id ->
> >>> >>     let m = Modifier.attach id in
> >>> >>       [ m Cast.total'k (fun (v,b) -> (v, max 1 (b-3)))     (* <--
> line
> >>> >> 462
> >>> >> *)
> >>> >>       ; m Lab.total'k (fun (v,b) -> (v, max 1 (b-3))) ])
> >>> >>
> >>> >> For reference, the signature of Modifier.attach:
> >>> >>   Db.key -> int * ('a list -> exn) * (exn -> 'a list) -> 'a ->
> >>> >> Modifier.deleter
> >>> >>
> >>> >> OCaml version is 4.00.0 -- I know I should upgrade. Keep meaning
> to, I
> >>> >> guess I will if I wake up and there's no helpful soul explaining
> what
> >>> >> could
> >>> >> be wrong here. :)
> >>> >>
> >>> >> Thank-you for any help. My eyes are starting to bug-out looking at
> >>> >> this.
> >>> >>
> >>> >>  -Tony
> >>> >>
> >>> >>
> >>> >
> >>
> >>
> >
>

[-- Attachment #2: Type: text/html, Size: 8051 bytes --]

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

end of thread, other threads:[~2013-04-13 17:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-13  6:50 [Caml-list] Types look compatible, but they aren't? Anthony Tavener
2013-04-13  6:56 ` Kakadu
2013-04-13  7:33   ` Gabriel Scherer
2013-04-13 16:07     ` Anthony Tavener
2013-04-13 16:15       ` Anthony Tavener
2013-04-13 17:14         ` Gabriel Scherer
2013-04-13 17:25           ` Anthony Tavener

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