[GHC] #14155: GHC mentions unlifted types out of the blue (to me anyway)
GHC
ghc-devs at haskell.org
Thu Aug 24 19:55:13 UTC 2017
#14155: GHC mentions unlifted types out of the blue (to me anyway)
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
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 -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`
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14155>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list