[Haskell-cafe] Writing guards shorthand

Neil Mitchell ndmitchell at gmail.com
Thu Apr 19 09:02:50 EDT 2007


Hi

isBool x = isLT x || isGT x
isNum x = not $ isBool x

isLT and isGT can be derived automatically using derve [1], with the
Is class (or DrIFT if you want).

Thanks

Neil

[1] 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
> (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.
>
>         Thanks, Joel
>
> --
> http://wagerlabs.com/
>
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list