[<<][haskell][>>][..]
Sat Jul 7 16:55:11 EDT 2018

Functor composition

Took me a while to figure out how to approach this, but it's really
simple when you focus on the types.

Functor compositions tend to pop up in ad-hoc places.  It is important
to realize that it is not necessary to use the Data.Functor.Compose
wrapper.

It is often simpler and clearer to only define a specialized mapping
function.  E.g.

mapBindings :: (a -> b) -> [(a, Term (Op a))] -> [(b, Term (Op b))]
mapBindings f l = map f' l where
  f' (name, term) = (f name, (fmap . fmap) f term)

I still find the implementation hard to read, but the type is really
clear, so the approach is to write that first, then compose fmap and
any specialized mapping functions as needed.





[Reply][About]
[<<][haskell][>>][..]