
6 Feb
2010
6 Feb
'10
5:38 a.m.
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