Lazy bind...

MR K P SCHUPKE k.schupke@ic.ac.uk
Tue, 30 Jul 2002 18:43:28 +0100


The data types I used are:

data (Error e) => Reply e s a= Ok [s] a | Empty | Fail e
data (Error e) => Result e s a = Accepted (Reply e s a) | Rejected

newtype (Error e) => Parser e s a = Parser {runParser :: [s] -> Result e s a}

newtype (Error e,Monad m) => ParserT e s m a = ParserT {runParserT :: [s] ->
m (Result e s a)}

data ParserError = UnspecifiedError | ErrorMsg String deriving Show
instance Error ParserError where
    noMsg = UnspecifiedError
    strMsg s = ErrorMsg s

    Hope this makes things clearer...


    Regards,
    Keean Schupke
    Department of Electrical & Electronic Engineering,
    Imperial College London.

Ken Shan wrote:

> Can you please give your definition of the Parser and ParserT type
> constructors?  My guesses are:
>
>     data State          = ...
>     data Message        = ...
>     data Accept a       = Fail Message | Empty | Ok State a
>     data Decide a       = Rejected | Accepted a
>
>     data Parser a       = Parser (State -> Decide (Accept a))
>     data ParserT m a    = Parser (State -> m (Decide (Accept a)))
>
> I wonder if it wouldn't be possible to redefine ParserT as
>
>     data ParserT m a    = Parser (State -> m (Decide (m (Accept a))))
>
> ?
>
> --
> Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
> The trick is that there is no trick.
>
>   ------------------------------------------------------------------------
>    Part 1.2Type: application/pgp-signature