module Data.Bifunctor.Clown
( Clown(..)
) where
import Control.Applicative
import Data.Biapplicative
import Data.Bifoldable
import Data.Bitraversable
import Data.Foldable
import Data.Monoid
import Data.Traversable
newtype Clown f a b = Clown { runClown :: f a }
deriving (Eq,Ord,Show,Read)
instance Functor f => Bifunctor (Clown f) where
first f = Clown . fmap f . runClown
second _ = Clown . runClown
bimap f _ = Clown . fmap f . runClown
instance Functor (Clown f a) where
fmap _ = Clown . runClown
instance Applicative f => Biapplicative (Clown f) where
bipure a _ = Clown (pure a)
Clown mf <<*>> Clown mx = Clown (mf <*> mx)
instance Foldable f => Bifoldable (Clown f) where
bifoldMap f _ = foldMap f . runClown
instance Foldable (Clown f a) where
foldMap _ = mempty
instance Traversable f => Bitraversable (Clown f) where
bitraverse f _ = fmap Clown . traverse f . runClown
instance Traversable (Clown f a) where
traverse _ = pure . Clown . runClown