
27 Jul
2006
27 Jul
'06
4:57 a.m.
On Wed, 26 Jul 2006, Fritz Ruehr wrote:
On Jul 26, 2006, at 6:44 PM, Sebastian Sylvan wrote:
For example ...
if :: Bool -> a -> a -> a if True t _ = t if False _ e = e
-- example usage myAbs x = if (x < 0) (negate x) x
I suppose there might also be a case for flipping the arguments about like this:
if :: a -> a -> Bool -> a if t _ True = t if _ e False = e
This way it would follow foldr more closely, in recognition that the conditional is essentially the fold/cata/eliminator/... for booleans.
I found the argument order of the first if (Bool -> a -> a -> a) already useful for a 'case' with computed conditions: select = foldr (uncurry if_) http://www.haskell.org/hawiki/Case