[Haskell-beginners] Re: Monadic composition without throwing genericity under the bus?

Heinrich Apfelmus apfelmus at quantentunnel.de
Sat Feb 6 05:38:11 EST 2010


Stephen Tetley wrote:
> The parser has a type restricted return type - always a 'Hughes
> string' with efficient concatenation (ShowS :: String -> String)
> rather than some polymorphic answer (e.g a parse tree). For formatting
> it allows you to add text without consuming any:
> 
> inserttext :: String -> Parser
> inserttext str = return (showString str)
> 
> Or rewrite matched input:
> 
> rewrite :: String -> String -> Parser
> rewrite inp out = string inp >> return (showString out)
> 
> Or drop text, I presume this is what the place combinator does.
> 
> Its a nice technique.

Ah, nice; thanks for the explanation!


Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



More information about the Beginners mailing list