[Haskell-beginners] Mapping list over datatype using Traversable and State monad.
Dmitriy Matrosov
sgf.dma at gmail.com
Tue Sep 25 15:42:00 CEST 2012
On Mon, 24 Sep 2012 16:35:45 -0400
Brent Yorgey <byorgey at seas.upenn.edu> wrote:
> My one suggestion might be to abstract out the "zippy apply" pattern,
> like so:
>
> zipApp :: Traversable f => [a -> b] -> f a -> f b
> zipApp fs = fst . flip runState fs . T.mapM f
> where
> f x = ... etc, same as above
>
> Then inlineSeps g = zipApp (id : repeat g), and you can reuse zipApp
> for other things.
Thanks! This is nicer, indeed. Perhaps, the last piece i'm missed for :)
More information about the Beginners
mailing list