module Control.Functor.Pointed
( Pointed(..)
, Copointed(..)
, PPointed(..)
, PCopointed(..)
) where
import Control.Functor
import Control.Category
import Control.Category.Hask
import Control.Monad.Identity
import Prelude hiding ((.),id)
class Functor f => Pointed f where
point :: a -> f a
class Functor f => Copointed f where
extract :: f a -> a
instance Pointed Identity where
point = Identity
instance Pointed Maybe where
point = Just
instance Pointed (Either a) where
point = Right
instance Pointed [] where
point a = [a]
instance Copointed Identity where
extract = runIdentity
instance Copointed ((,)e) where
extract = snd
class PFunctor f Hask Hask => PPointed f where
preturn :: a -> f a c
class PFunctor f Hask Hask => PCopointed f where
pextract :: f a c -> a