[Haskell-cafe] Re: Search monad

apfelmus apfelmus at quantentunnel.de
Tue Mar 20 11:34:33 EDT 2007


Edsko de Vries wrote:
> Hey,
> 
> I have a structure containing Xs in various places, like so
> 
> data X
> data Structure = Structure .. [X] .. [X] ..
> 
> And I defined mapStructure 
> 
> mapStructure :: (X -> X) -> (Structure -> Structure)
> 
> I then wanted to use mapStructure to define queries as well as
> transformations on structures. I generalized mapStructure to
> mapStructureM:
> 
> mapStructure :: Monad m => (X -> m X) -> (Structure -> m Structure)

I guess you want an applicative functor. See also

http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Traversable.html

and the accompanying papers.

Regards,
apfelmus



More information about the Haskell-Cafe mailing list