[Haskell-cafe] Re: Brainstorming on how to parse IMAP

ChrisK haskell at list.mightyreason.com
Tue Aug 5 14:39:59 EDT 2008


Hi John,

   I recently posted new and fancy binary Get monads in
http://article.gmane.org/gmane.comp.lang.haskell.libraries/9691
and
http://article.gmane.org/gmane.comp.lang.haskell.libraries/9756
which might be of interest since network protocol are usually specified in bytes 
at the wire level.

   The latest one takes input which may or may not be complete and returns a 
stream (a Seq) of results.  When it reaches the end of the input it pauses and 
asks for more.  This handling of partial input might be good for network 
protocols where you can feed the data from the socket to the parser in pieces. 
(This Get monad eats lazy bytestrings).

   The latest MyGetW.hs allows the Get code to send a Data.Sequence.Seq of 
results by using yieldItem (and perhaps flushItems).  This is in addition to any 
final result of the parser.

It has the usual binary Get interface, so you can pull bytestrings and words and 
(fancy) any Storable off the input.

   I call it "fancy" because the monad is a transformer, and it is a 
MonadError/MonadPlus/Alternative, and it supports lookAhead and callCC/MonadCont 
and Reader/Writer/State.  Whew.

As for IMAP, I use imapfilter (http://imapfilter.hellug.gr/) which uses Lua.

Cheers,
   Chris



More information about the Haskell-Cafe mailing list