id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,testcase,blockedby,blocking,related,differential,wikipage
14155,GHC mentions unlifted types out of the blue (to me anyway),Iceland_jack,goldfire,"This one does me 'ead in, I accidentally type `Ran` instead of `Swap`
{{{#!hs
{# 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 ignoredotghci /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`",bug,new,normal,8.8.1,Compiler,8.2.1,,TypeInType,RyanGlScott,Unknown/Multiple,Unknown/Multiple,None/Unknown,,,,,,