Am 08.10.2011 16:04, schrieb Captain Freako:
Hi all,
In this definition from the Parsec library:
parse :: (Stream s Identity t)
=> Parsec s () a -> SourceName -> s -> Either ParseError a
parse p = runP p ()
what's the significance of `Identity t'?
(`t' isn't used anywhere.)
http://hackage.haskell.org/packages/archive/parsec/3.1.2/doc/html/Text-Parsec-Prim.html#t:Stream
Text.Parsec.Prim contains
class Monad m => Stream s m t | s -> t where
saying that the type s determines t (that is a functional dependency).
The instances are:
Monad m => Stream ByteString m Char
Monad m => Stream ByteString m Char
Monad m => Stream Text m Char
Monad m => Stream Text m Char
Monad m => Stream [tok] m tok
so usually you have a character stream. (There are lazy and strict
version of Text and ByteString.) The last instance also works for plain
strings (String = [Char]).
Using "Identity" for the monad m just means, that you actually do not
need a monad (but need to supply a dummy one).
If you want to keep thinks simpler you could use packages parsec1 or parsec2
Cheers Christian
http://hackage.haskell.org/package/parsec2
http://hackage.haskell.org/package/parsec1
Thanks,
-db
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe