[GHC] #9106: GHC Panic related to functional dependencies - kindFunResult
GHC
ghc-devs at haskell.org
Thu May 22 07:41:15 UTC 2014
#9106: GHC Panic related to functional dependencies - kindFunResult
---------------------------------------+---------------------------
Reporter: yuriy | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.2
Resolution: | Keywords:
Operating System: Windows | Architecture: x86
Type of failure: Compile-time crash | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
---------------------------------------+---------------------------
Comment (by darchon):
The type family version also works:
{{{
{-# LANGUAGE DataKinds, FlexibleInstances, MultiParamTypeClasses,
PolyKinds,
ScopedTypeVariables, TypeFamilies, TypeOperators, UndecidableInstances
#-}
module FunctorN where
import GHC.TypeLits
data Proxy (a :: k) = Proxy
type family F n f a
where
F 0 f a = a
F n f a = f (F (n-1) f a)
class F n f a ~ fa => FunctorN n f a fa where
fmapn :: Proxy n -> Proxy f -> (a -> a) -> fa -> fa
instance FunctorN 0 f a a where
fmapn _ _ a = a
instance ( Functor f, FunctorN (n-1) f a fa, F (n - 1) f a ~ fa
, F n f a ~ f fa) => FunctorN n f a (f fa) where
fmapn _ pf f = fmap (fmapn (Proxy :: Proxy (n-1)) pf f)
test :: Maybe (Maybe (Maybe Int))
test = fmapn (Proxy :: Proxy 3) (Proxy :: Proxy Maybe) (+1)
(Just (Just (Just 3)))
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9106#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list