
3 Mar
2009
3 Mar
'09
7:17 a.m.
On Tue, Mar 03, 2009 at 01:53:44AM -0500, wren ng thornton wrote:
If you're just wanting to build Exprs, then the canonical solution is to use ':' as in (:>), (:>=), (:==), (:/=), (:<=), (:<). The colon is considered a "capital symbol" and so it's what you use as the first letter of symbolic constructors. For symmetry, many folks will ad another colon at the end as well.
data Expr = Const Integer | Expr :+: Expr | Expr :*: Expr | Expr :>: Expr | ...
Alas, in several instances (too long to give here) it's impractical to write the DSL just as constructors--several of the operators have to do nontrivial computation. (Plus, I'd still call the :*: solution ugly, personally.) Is it possible to do better? AHH