[Haskell-cafe] combinators for a simple grammar

Jonathan Cast jcast at ou.edu
Mon Aug 6 22:49:58 EDT 2007


On Monday 06 August 2007, Rahul Kapoor wrote:
> I am having problems coming up with nice combinators for a simple
> DSEL. The abstract syntax is simply given by the types:

<snip>

> Or is it a better idea to just remove the precedence rules from the
> types and move it the part of the code that evaluates the expressions?

Exactly thus.  Say:

data SearchCondition
  = Constant Bool
  | SearchCondition :||: SearchCondition
  | SearchCondition :&&: SearchCondition

infixr 3 (:&&:)
infixr 2 (:||:)

And you're set.

Jonathan Cast
http://sourceforge.net/projects/fid-core
http://sourceforge.net/projects/fid-emacs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070806/5998537b/attachment.bin


More information about the Haskell-Cafe mailing list