[Haskell-cafe] Problem with lazy IO

Maciej Piechotka uzytkownik2 at gmail.com
Sat Jul 18 21:16:07 EDT 2009


I've tried to combine lazy IO and parsec. The hole process is done by

Currently I have implemented 'short parsers' so I enter them on need. To
update state I have following code:
parser2nntp :: Monad m => NntpParser m a -> NntpT m a
parser2nntp p = do s <- NntpT (gets $ input . connection)
                   e <- runParserT (do v <- p
                                       i <- getInput
                                       return (v, i)) () "" s
                   case e of
                     Left er -> error $ show er
                     Right (v, i') -> (NntpT (modify (pNI i')) >> return
                where pNI :: Monad m => ByteString ->NntpState m ->
NntpState m
                      pNI i s = s {connection = (connection s) {input =

However the 4 line (i <- getInput) blocks the execution as trace
indicated. String returned have no input available so it should block on
evaluation - and here I pass only a reference to it (or rather I think
so). What's wrong? 

PS. Full code is in darsc nntp repository http://code.haskell.org/nntp/
- please note that it seems to require network compiled against parsec 3
- not 2.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090718/50006493/attachment.bin

More information about the Haskell-Cafe mailing list