[Haskell-cafe] Re: Writing guards shorthand

Isaac Dupree isaacdupree at charter.net
Thu Apr 19 11:32:27 EDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jón Fairbairn wrote:
> Is there some reason why you don't want
> 
>    data Op = Aop Aop | Bop Bop
>    data Aop = Minus | Plus | Mul
>    data Bop = LT | GT
> 
> or similar?  I would agree that it's a shame one cannot just write
> 
>    data Op = Aop (Minus | Plus | Mul) | Bop (LT | GT)
> 
> or even, given a somewhat different type system,
> 
>    data Op = Aop | Bop
>              where Aop = Minus | Plus | Mul
>                    Bop = LT | GT
> 
> but it would seem reasonable to reflect the different types
> of the Ops in different types in their representations.
> 

Slightly off-topic, I had a problem like this, only where I wanted to
classify by more than one dimension: "readable?" as well as "writable?"
(some were none, some both, some just readable and some just writable),
so I couldn't split up the type hierarchically like that.  I think I
just wrote tedious functions to say whether each constructor was in each
category.

Isaac
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGJ4uLHgcxvIWYTTURAkKgAJ9N998vRVsmrhHuz/zoVJaHN3nuKgCcCSmX
qRFWGfKZGORAKI61J8153AI=
=eVR6
-----END PGP SIGNATURE-----


More information about the Haskell-Cafe mailing list