Idris2-boot icon indicating copy to clipboard operation
Idris2-boot copied to clipboard

Messing up parameters order of interfaces implementation

Open berewt opened this issue 4 years ago • 0 comments

In some cases (can't be more precise about the context unfortunately) the implementation of a typeclass with several parameters doesn't work, the compiler mixes up the parameter order. It can be resolve by making the parameters explicit in the signatures of the functions of the typeclass, but they have to be declared in a specific order.

Steps to Reproduce

Try to compile this file

public export
interface IxFunctor (f : (lbl : Type) -> (pre : List lbl) -> (post : List lbl) -> Type -> Type)
          where
  map : (a -> b) -> f ty pre post a -> f ty pre post b
public export
interface (IxFunctor f) =>
          IxApplicative (f : (lbl : Type) -> (pre : List lbl) -> (post : List lbl) -> Type -> Type)
          where
  pure  : {st : List lbl} -> a -> f lbl st st a
  (<*>) : f lbl pre inter (a -> b) -> f lbl inter post a -> f lbl pre post b
data Dummy : (lbl : Type) -> (pre, post : List lbl) -> Type -> Type where
  AmIDumb : a -> Dummy b pre post a
IxFunctor Dummy where
  map func (AmIDumb x) = AmIDumb (func x)
IxApplicative Dummy where
  pure x = ?pure_rhs
  (<*>) mf mx = ?app_rhs

Expected Behavior

It should compile.

Observed Behavior

Test.idr:23:1--38:1:While processing right hand side of IxApplicative implementation at Test.idr:23:1--38:1 at Test.idr:23:1--38:1:
When unifying Dummy lbl post a inter and Dummy lbl inter post a
When unifying Dummy lbl st st a and Dummy lbl st a st
Mismatch between:
	st
and
	a

berewt avatar Apr 24 '20 09:04 berewt