GHC mentions unlifted types out of the blue (to me anyway)
This one does me 'ead in, I accidentally type Ran
instead of Swap
{-# Language RankNTypes, DerivingStrategies, TypeApplications, ScopedTypeVariables, GADTs, GeneralizedNewtypeDeriving, InstanceSigs, PolyKinds #-}
import Data.Coerce
newtype Ran g h a = Ran (forall b. (a -> g b) -> h b)
newtype Swap p f g a where
Swap :: p g f a -> Swap p f g a
deriving newtype
Show
class IxPointed m where
ireturn :: a -> m i i a
instance IxPointed f => IxPointed (Swap f) where
ireturn :: forall a i. a -> Swap f i i a
ireturn a = Ran (ireturn a)
and get this error
$ ghci -ignore-dot-ghci /tmp/bug.hs
GHCi, version 8.3.20170605: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( /tmp/bug.hs, interpreted )
/tmp/bug.hs:17:15: error:
• Couldn't match expected type ‘Swap f i i a’
with actual type ‘Ran g0 h0 a0’
• In the expression: Ran (ireturn a)
In an equation for ‘ireturn’: ireturn a = Ran (ireturn a)
In the instance declaration for ‘IxPointed (Swap f)’
• Relevant bindings include
a :: a (bound at /tmp/bug.hs:17:11)
ireturn :: a -> Swap f i i a (bound at /tmp/bug.hs:17:3)
|
17 | ireturn a = Ran (ireturn a)
| ^^^^^^^^^^^^^^^
/tmp/bug.hs:17:20: error:
• Couldn't match a lifted type with an unlifted type
Expected type: (a0 -> g0 b) -> h0 b
Actual type: (->) (a0 -> g0 b) (a0 -> g0 b) a
• In the first argument of ‘Ran’, namely ‘(ireturn a)’
In the expression: Ran (ireturn a)
In an equation for ‘ireturn’: ireturn a = Ran (ireturn a)
|
17 | ireturn a = Ran (ireturn a)
| ^^^^^^^^^
Failed, modules loaded: none.
Is GHC right to bring up unlifted types? I would guess this is due to the newly added levity polymorphism of (->) :: TYPE rep -> TYPE rep' -> Type
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |