[Haskell-cafe] Writing guards shorthand
ndmitchell at gmail.com
Thu Apr 19 09:02:50 EDT 2007
isBool x = isLT x || isGT x
isNum x = not $ isBool x
isLT and isGT can be derived automatically using derve , with the
Is class (or DrIFT if you want).
 google "data derive"
On 4/19/07, Joel Reymont <joelr1 at gmail.com> wrote:
> Support I want to infer the type given an Op that looks like this
> 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
> I really don't want several function clauses and neither do I want
> separate guards for every constructor.
> Thanks, Joel
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe