[Haskell-cafe] Functor instance for FunPB

Alex Wede awede at techfak.uni-bielefeld.de
Sat May 6 17:50:29 UTC 2017


Hey Everyone,


ich have a algebraic data type:


data FunPB a b = FunPB { runFunPB :: a -> (a,[b]) }


I got a Monoid Instance

instance Monoid (FunPB a b) where
   mempty  = FunPB $ \k -> (k,mempty)
   mappend pb1 pb2 = FunPB $ \n -> (,) n $ msum . (<$>) (uncurry (flip 
const).((flip runFunPB) n)) $ [pb1,pb2]

Now I need to write a functor instance

instance Functor (FunPB a) where

     fmap f b = ?


How can I map over a->(a,[b])?


Lg

Alex



More information about the Haskell-Cafe mailing list