[Haskell-cafe] DSLs with {in,}equalities

Andrew Hunter ahunter at cs.hmc.edu
Tue Mar 3 02:17:28 EST 2009


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



More information about the Haskell-Cafe mailing list