arrows
Ashley Yakeley
ashley@semantic.org
Fri, 6 Dec 2002 18:42:15 -0800
At 2002-12-06 15:57, Wolfgang Jeltsch wrote:
>I cannot see how this relatively simple representation can be used to
>describe
>certain parsers. If I would use Identity for baseMonad, I would have a type
>for simple parsers. MyParser Identity would essentially be token -> output.
You can't use Identity for baseMonad. You would need to use something
that managed a stream. The idea is that your source is something of type
"baseMonad token", and by repeatedly calling source, you pull off
individual tokens.
>Which function of this type should be used to describe, for instance,
> (a) a parser reading no tokens and returning ()
MkMyParser (\_ -> return ())
> (b) a parser reading two tokens and returning the pair of these tokens?
MkMyParser (\source -> do
{
a <- source;
b <- source;
return (a,b);
})
You can then use parsers of type MyParser with all kinds of sources, such
as those that read items from a file, or a state transformer that pops
items off a list, or whatever.
--
Ashley Yakeley, Seattle WA