Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overly eager auto implicit in GADT ctor field's type results in typechecking failure #3223

Open
0xd34df00d opened this issue Mar 3, 2024 · 0 comments

Comments

@0xd34df00d
Copy link
Contributor

0xd34df00d commented Mar 3, 2024

Steps to Reproduce

Try typechecking

module Foo

interface SomeMonad (s : Type) (m : Type -> Type) where

data Operation : (res : Type) -> Type where
  Op : (opFun : forall s, m. SomeMonad s m => m r1) -> (cont : r1 -> Operation r2) -> Operation r2

Functor Operation where
  map f (Op opFun cont) = Op opFun (map f . cont)

Expected Behavior

Typechecks fine.

Observed Behavior

Fails with

Error: While processing right hand side of map. Can't find an implementation for SomeMonad ?s ?m.

Foo:9:30--9:35
 5 | data Operation : (res : Type) -> Type where
 6 |   Op : (opFun : forall s, m. SomeMonad s m => m r1) -> (cont : r1 -> Operation r2) -> Operation r2
 7 | 
 8 | Functor Operation where
 9 |   map f (Op opFun cont) = Op opFun (map f . cont)
                                  ^^^^^

If we replace the opFun at the rhs with a hole and look at its type, it'd be

rhs : m r1

instead of the (expected) SomeMonad s m => m r1, so surely it fails to find the implementation.

Note 1: removing s from both SomeMonad definition and from forall in the Op definition makes it compile, albeit the hole type is still funny and lacks the SomeMonad m => constraint.

Note 2: adding a dummy argument like

data Operation : (res : Type) -> Type where
  Op : (opFun : () -> forall s, m. SomeMonad s m => m r1) -> (cont : r1 -> Operation r2) -> Operation r2

also makes things compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant