[GHC] #12592: Explicit type signature for type classes fails
GHC
ghc-devs at haskell.org
Mon Sep 12 20:03:04 UTC 2016
#12592: Explicit type signature for type classes fails
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.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:
-------------------------------------+-------------------------------------
GHC 8.0.1: Consider the [https://hackage.haskell.org/package/indexed-0.1
indexed classes]:
{{{#!hs
class IxFunctor f where
imap :: (a -> b) -> f j k a -> f j k b
class IxFunctor m => IxPointed m where
ireturn :: a -> m i i a
class IxPointed m => IxApplicative m where
iap :: m i j (a -> b) -> m j k a -> m i k b
class IxFunctor w => IxCopointed w where
iextract :: w i i a -> a
class IxApplicative m => IxMonad m where
ibind :: (a -> m j k b) -> m i j a -> m i k b
class IxMonad m => IxMonadFree f m | m -> f where
iwrap :: f i j (m j k a) -> m i k a
}}}
GHCi gives their kinds:
{{{
IxFunctor :: (k -> i -> * -> *) -> Constraint
IxPointed :: (k -> k -> * -> *) -> Constraint
IxApplicative :: (k -> k -> * -> *) -> Constraint
IxCopointed :: (k -> k -> * -> *) -> Constraint
IxMonad :: (k -> k -> * -> *) -> Constraint
IxMonadFree :: (k -> k -> * -> *) -> (k -> k -> * -> *) -> Constraint
}}}
so I attempt to make them explicit:
{{{#!hs
type IxFunct i = i -> i -> Type -> Type
class IxFunctor (f :: IxFunct i) where
imap :: (a -> b) -> f j k a -> f j k b
}}}
Works fine, but if I add it to any of the others it fails:
{{{#!hs
-- tZRa.hs:15:17: error: …
-- • Expected kind ‘i’, but ‘i’ has kind ‘*’
-- • In the first argument of ‘w’, namely ‘i’
-- In the type signature:
-- iextract :: w i i a -> a
-- In the class declaration for ‘IxCopointed’
-- Compilation failed.
class IxFunctor w => IxCopointed (w :: IxFunct i) where
iextract :: w i i a -> a
-- ...
class IxMonad m => IxMonadFree (f :: IxFunct i) (m :: IxFunct i) | m -> f
where
iwrap :: f i j (m j k a) -> m i k a
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12592>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list