[Haskell-cafe] Re: Writing guards shorthand

2007-04-19 Thread Jón Fairbairn
Joel Reymont [EMAIL PROTECTED] writes:

 Support I want to infer the type given an Op that looks like
 this  (incomplete):
 
 data Op
  = Minus
  | Plus
  | Mul
  | LT
  | GT
 
 Is there a shorthand way of bunching Minus, Plus and Mul in
 a  function guard since they all result in TyNum whereas the
 rest in  TyBool?
 
 I really don't want several function clauses and neither do
 I want  separate guards for every constructor.

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.

-- 
Jón Fairbairn [EMAIL PROTECTED]


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Writing guards shorthand

2007-04-19 Thread Joel Reymont


On Apr 19, 2007, at 4:10 PM, 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


It's a long story. The short version is that the above will  
complicate my AST a whole lot. I had it this way before.


Thanks, Joel

--
http://wagerlabs.com/





___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Writing guards shorthand

2007-04-19 Thread Isaac Dupree
-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-
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe