Parser combinator problem

From: Steffen Mazanek <>
Date: Fri, 08 Feb 2008 11:31:25 +0100


I have a question regarding the <*> operator (successive
application) known from parser combinator libraries,

Normally, I would define it as follows:

(<*>)::Parser (res1->res2)->Parser res1->Parser res2
(p1 <*> p2) g = (pv qv, g'')
   (pv, g') = p1 g
   (qv, g'') = p2 g'

However, applied to real input this results in stack overflow
in the Münster Curry Compiler and non- or really late
termination in PACKS.

If I use this formulation, no problems occur:

(p1 <*> p2) g | p1 g =:= (pv,g') & p2 g' =:= (qv, g'') = (pv qv, g'')
   where g',g'',pv,qv free

However, I think, that the latter one is not as intuitive as the
first one, so I wonder why it performs so much better.

Any hints are greatly appreciated!

Steffen Mazanek

curry mailing list
Received on Fr Feb 08 2008 - 14:19:47 CET

This archive was generated by hypermail 2.3.0 : Sa Dez 09 2023 - 07:15:10 CET