Re: Another parser combinator problem

From: Wolfgang Lux <wlux_at_uni-muenster.de>
Date: Mon, 25 Feb 2008 16:48:00 +0100

Steffen Mazanek wrote:

> Adopted to graphs the result looks as follows:
>
> -- primitive parser for edges, edge c need not be first element of
> list
> edge::Edge->Grappa ()
> edge c _ g | g=:=g1++c:g2 = ((),[],g1++g2)
> where g1,g2 free
> edge c (S _) g | c `notInGraph` g = ((),[c],g)
>
> notInGraph c [] = success
> notInGraph c (x:xs) | c=/=x = notInGraph c xs
>
> I need to check notInGraph before assuming an edge, because I
> want to consume the given edges first. Is this the right way to
> ensure such constraints in Curry? This code works with MCC,
> how can I realize this in PAKCS? Is there a more standard way?


You can work around the absence of disequality constraints in
PAKCS with the definition
   infix 4 =/=
   x=/=y | x/=y = success
The problem of this definition is that it blocks for non-ground
arguments. So you may need to add suitable generator functions
to instantiate c and/or g in the c `notInGraph` g guard if this
is a problem for you.

Regards
Wolfgang

_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Mo Feb 25 2008 - 17:46:18 CET

This archive was generated by hypermail 2.3.0 : Do Feb 01 2024 - 07:15:08 CET