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

Stephen Tetley stephen.tetley at gmail.com
Thu Feb 4 06:25:36 EST 2010


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.



On 4 February 2010 10:46, Heinrich Apfelmus <apfelmus at quantentunnel.de> wrote:
>
> This looks intriguing! Can you elaborate on how this works?


More information about the Beginners mailing list