I've attempted to define a Parsec combinator thus:
[[
notMatching :: Show a => GenParser tok st a -> GenParser tok st ()
notMatching p = try ( do { a <- p ; unexpected (show a) } <|> return () )
]]
It's modelled on the Parsec-provided combinator 'notFollowedBy', but is
less fussy about the type o
On Tue, Feb 17, 2004 at 06:42:39PM +, Graham Klyne wrote:
> I've attempted to define a Parsec combinator thus:
>
> [[
> notMatching :: Show a => GenParser tok st a -> GenParser tok st ()
> notMatching p = try ( do { a <- p ; unexpected (show a) } <|> return () )
> ]]
If p fails but consumes s
Thanks! That got me going, though not with quite what you suggested.
I ended up with this:
[[
notMatching :: Show a => GenParser tok st a -> GenParser tok st ()
notMatching p = do { a <- try p ; unexpected (show a) } <|> return ()
]]
which does the required job for me.
Using your version caused t
On Tue, Feb 17, 2004 at 07:48:52PM +, Graham Klyne wrote:
> Thanks! That got me going, though not with quite what you suggested.
>
> I ended up with this:
> [[
> notMatching :: Show a => GenParser tok st a -> GenParser tok st ()
> notMatching p = do { a <- try p ; unexpected (show a) } <|> re
On Tue, Feb 17, 2004 at 04:57:34PM -0500, Andrew Pimlott wrote:
> What about a more prosaic implementation:
>
> notFollowedBy' :: Show a => GenParser tok st a -> GenParser tok st ()
> notFollowedBy' p= do res <- do a <- try p; return $ Just a
> <
On Wed, 18 Feb 2004 01:11:31 -0500, Andrew Pimlott <[EMAIL PROTECTED]> wrote:
After some pondering and fiddling, a version I like:
notFollowedBy' :: Show a => GenParser tok st a -> GenParser tok st ()
notFollowedBy' p= join $ do a <- try p; return (unexpected (show a))
On Wed, Feb 18, 2004 at 02:45:15PM +0100, Daan Leijen wrote:
> On Wed, 18 Feb 2004 01:11:31 -0500, Andrew Pimlott <[EMAIL PROTECTED]>
> wrote:
> >After some pondering and fiddling, a version I like:
> >
> >notFollowedBy' :: Show a => GenParser tok st a -> GenParser tok st ()
> >notFollowed
On Wed, Feb 18, 2004 at 02:45:15PM +0100, Daan Leijen wrote:
> On Wed, 18 Feb 2004 01:11:31 -0500, Andrew Pimlott <[EMAIL PROTECTED]>
> wrote:
> >After some pondering and fiddling, a version I like:
> >
> >notFollowedBy' :: Show a => GenParser tok st a -> GenParser tok st ()
> >notFollowed
Hi,
In a local copy of Parsec.Prim I've added a primitive, that may be of
help for your problem as well.
consumeNothing :: GenParser tok st ()
consumeNothing = Parser (\state -> Consumed (Ok () state (unknownError
state)))
With this I've implemented:
checkWith :: (Show a) => GenParser tok st