[Haskell-cafe] IO within parser

Andrew Coppin andrewcoppin at btinternet.com
Sat Aug 11 16:25:16 EDT 2007

Gregory Propf wrote:
> I've been struggling with writing a parser that needs to parse include 
> files within source files.  So far I cannot get this to work (in 
> reality to get work done I wrote a kludge that returns a list of 
> include filenames to be run later in a pure IO function.  I realized 
> that this just amounted to creating my own half-assed monad system so 
> I really don't want to use this approach).  I have read the tutorials 
> I could find on monad transformers but I still don't see what's going 
> on.  I'm using the Parsec parser library. Here's an simple example of 
> what I've tried.  I also tried using liftIO and got a message about 
> needing to add an instance of MonadIO.  This made more sense but the 
> type of liftIO is baffling

The fun part is that Parsec already has a feature for include files... 
(I can't remember where the heck it is or how you use it though.)

More information about the Haskell-Cafe mailing list