type check error (higher order unification?)

12 views
Skip to first unread message

Tao Yang

unread,
Jun 4, 2016, 2:13:42 PM6/4/16
to core.typed
Hi,

I run into a problem while trying to add type annotations to funcool/cats. I started with two very basic things, monoid and semigroup. There is a type error on this line of test

Type Error (cats/typed/core.clj:24:21)
Type mismatch:

Expected:     (t/All [x] (t/Option (t/I Context (t/U (Semigroup x) (Monoid x)))))

Actual:     (t/I Context (Monoid t/Bool))


Type Error (cats/typed/core.clj:24:3)
Function cats.protocols/-get-level could not be applied to arguments:


Domains:
   
Context

Arguments:
   
(t/All [x] (t/Option (t/I Context (t/U (Monoid x) (Semigroup x)))))

Ranges:
    t
/Num


For me as someone with no exposure to type theory,
(I Context (Monoid Bool))
does not contradict to
(All [x] (Option (I Context (U (Monoid x) (Semigroup x)))))

However I think it's more likely that I've done something stupid. Any idea please?

Thanks,
Tao

Ambrose Bonnaire-Sergeant

unread,
Jun 7, 2016, 11:44:59 PM6/7/16
to core.typed
Hi Tao,

Unfortunately core.typed is currently bad at this kind of thing.

Try using a TFn instead of All here, and any other place that
isn't just defining a polymorphic function.

Thanks,
Ambrose
Reply all
Reply to author
Forward
0 new messages