Hallo.

You can try reusing fmap.

>>>

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

fmap f (FunPB g) = FunPB $ fmap (fmap (fmap f)) g

>>>

This works because (a->), (a,), and [] are all functors.

Freundliche Grüße,
Daniel.

On Sat, May 6, 2017 at 9:04 PM, MarLinn <monkleyon@gmail.com> wrote:

On 2017-05-06 20:38, David Kraeutmann wrote:
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.
And because it's closer to the original style:

        fmap f = FunPB .((.)((<$>).(<$>)$f)). runFunPB

Now it's STARRING INTO YOU SOUL. And it's also so much easier to read.


_______________________________________________
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.