makeSem_ - "would escape its scope" - Polysemy

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Sridhar Ratnakumar

For this type,

data DListLang (f :: Type -> Type) m a where
  AddX :: DSum f Identity -> DListLang f m ()

makeSem_ ''DlistLang

the compiler throws,

src/Self/Feeling.hs:80:1-20: error:
    • Couldn't match type ‘p’ with ‘DMap.DSum f1 Identity’
        because type variable ‘f1’ would escape its scope
      This (rigid, skolem) type variable is bound by
        an expression type signature:
          forall (f1 :: * -> *) (r1 :: EffectRow). DListLang f1
(Sem r1) ()
        at src/Self/Feeling.hs:80:1-20
      Expected type: DSum f1 Identity
        Actual type: p
    • In the first argument of ‘AddX’, namely ‘x_a6wcj’
      In the first argument of ‘Polysemy.Internal.send’, namely
        ‘(AddX x_a6wcj :: DListLang f (Sem r) ())’
      In the expression:
        Polysemy.Internal.send (AddX x_a6wcj :: DListLang f (Sem
r) ())
    • Relevant bindings include
        x_a6wcj :: p (bound at src/Self/Feeling.hs:80:1)
        addX :: p -> Sem r () (bound at src/Self/Feeling.hs:80:1)
80 | makeSem_ ''DListLang
   | ^^^^^^^^^^^^^^^^^^^^

Is there a limitation here?


I'm putting this here since I think it will be quick:

Can someone tell me why I'm getting this error?

[bios] [E]  Expected kind Effect, but Console has kind * -> * -> *
 In the first argument of MemberWithError, namely Console
  In the type signature:
    readLine :: forall r_a9N1.
                MemberWithError Console r_a9N1 => Sem r_a9N1 String

With this code

data Console m a where
  WriteLine :: String -> Console m ()
  ReadLine  :: Console m String

makeSem ''Console

Had to enable Polykinds!


Or use explicit annotations on m and a
Or write data Console :: Effect where ..