
The only lawful instance I can think of is: instance Functor (FunPB a) where fmap f (FunPB g) = FunPB $ \k -> let (a,b) = g k in (a, fmap f b) which is fairly straightforward IMO. On 2017-05-06 19:50, Alex Wede wrote:
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
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.