Skip to content

Inferred type signature fails to unify ability type-params #6207

@ChrisPenner

Description

@ChrisPenner

This fails to compile unless I uncomment the type signature of todoHandle;

examples.books.logic : msg ->{Process e} ()
examples.books.logic _msg = match getCommandAutocomplete() with
  OrderRelated _kind        -> todoHandle ()
  ReturnStatus           -> todoHandle ()
  GiftCardStatus         -> todoHandle ()
  GiftCardPurchase      -> todoHandle ()
  NotficationRequest     -> todoHandle ()
  BookQuestion          -> todoHandle ()
  TalkToHuman          -> todoHandle ()
  FAQ                  -> todoHandle ()

-- todoHandle : '{Process e} ()
todoHandle = do
  books.logic ()

It fails with

  The expression in red needs the {Process e246} ability, but this location only has access to the {Process e255} ability,

     99 | examples.books.logic _msg = match getCommandAutocomplete() with

If I add the explicit type signature to todoHandle it unifies just fine.

I tried to minimize this with something like:

structural ability MyAbility e where
  incrementNat :  Nat -> Nat
  fail : e -> ()

useAbility : Nat -> {MyAbility e} Nat
useAbility n =
  match incrementNat n with
    1 -> doTheThing ()
    2 -> doTheThing ()
    _ -> 1

-- doTheThing : '{MyAbility e} Nat
doTheThing = do incrementNat  1

But this didn't trigger the error, so unfortunately there must be something going on that I don't understand 🤔

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions