Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  combining a trifecta parser with FreshMT     from unbound
      (Andreas Reuleaux)


----------------------------------------------------------------------

Message: 1
Date: Thu, 31 Jul 2014 00:42:49 +0100
From: Andreas Reuleaux <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] combining a trifecta parser with
        FreshMT from unbound
Message-ID: <[email protected]>
Content-Type: text/plain

OK, I have made some progress, and have uploaded two programs to
lpaste.net

* one that works:
  trifecta + unbound, works:
  http://lpaste.net/108457

* and one that doesn't
  trifecta + unbound, fails
  http://lpaste.net/108458

the working version is simpler, in that it defines PiParser just as a
type synonym

  type PiParser = FreshMT InnerParser

maybe I should be happy already that I got that working, e.g.

> parseTest (runInnerParser $ runFreshMT $ whiteSpace *> many identifier) " wow 
> {- bla -} this rocks"
> ["wow","this","rocks"]

to install: cabal install trifecta + unbound in a sandbox e.g.


Now in the second version, I have in addition wrapped the FreshMT in a newtype

  newtype FreshT m a = F {
    runF :: FreshMT m a
     } deriving (Monad, Functor, Applicative, MonadPlus, MonadTrans)

  type PiParser = FreshT InnerParser

While this might not be necessary in this simple case here,
I can imagine situations, where doing so might come in handy.

Consequently have to add a few more instances for the parser:

  instance CharParsing PiParser where
  etc.
  

and of course I need an additional step of unwrapping with runF

  runInnerParser $ runFreshMT $ runF someparser

(In both versions TokenParser is defined on the PiParser)


I would expect that I can parse something like the above test string
similarily, but unfortunately this is not the case:


> parseTest (runInnerParser $ runFreshMT $ runF (whiteSpace *> many 
> identifier)) "  oh too {- bla -} bad"
[]

I can at most parse one letter:

> parseTest (runInnerParser $ runFreshMT $ runF (whiteSpace *> identifier)) "oh 
> too {- bla -} bad"
"o"

I don't really see, how wrapping the FreshMT in a newtype harms the parser?

Thanks in advance

-Andreas


------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 73, Issue 21
*****************************************

Reply via email to