module Generics.Pointless.Fctrable where
import Prelude hiding (Functor(..),fmap)
import Generics.Pointless.Functors
import Generics.Pointless.Combinators
data Fctr (f :: * -> *) where
I :: Fctr Id
K :: Fctr (Const c)
(:*!:) :: (Functor f,Functor g) => Fctr f -> Fctr g -> Fctr (f :*: g)
(:+!:) :: (Functor f,Functor g) => Fctr f -> Fctr g -> Fctr (f :+: g)
(:@!:) :: (Functor f,Functor g) => Fctr f -> Fctr g -> Fctr (f :@: g)
class (Functor f) => Fctrable (f :: * -> *) where
fctr :: Fctr f
instance Fctrable Id where
fctr = I
instance Fctrable (Const c) where
fctr = K
instance (Functor f,Fctrable f,Functor g,Fctrable g) => Fctrable (f :*: g) where
fctr = (:*!:) fctr fctr
instance (Functor f,Fctrable f,Functor g,Fctrable g) => Fctrable (f :+: g) where
fctr = (:+!:) fctr fctr
instance (Functor f,Fctrable f,Functor g,Fctrable g) => Fctrable (f :@: g) where
fctr = (:@!:) fctr fctr
fixF :: Fctr f -> Fix f
fixF (_::Fctr f) = (_L :: Fix f)
fctrF :: Fctrable f => Fix f -> Fctr f
fctrF (_::Fix f) = fctr :: Fctr f