Quoth "Sebastian Sylvan" :
| On 7/27/06, mvanier wrote:
| > As opposed to what?
|
| For example case-of, guards (in combination with let or where), or
| just a function:
|
| if :: Bool -> a -> a -> a
| if True t _ = t
| if False _ e = e
|
| -- example usage
| myAbs x = if (x < 0) (negate x) x
That looks to me like a different way to spell if then else, but maybe
that's the answer to the question - conceptually, for every "then" there
really is an "else", however you spell it, and only in a procedural language
does it make any sense to leave it implicit. The exception that proves the
rule is "else return ()" -, e.g.,
if_ :: Bool -> IO () -> IO ()
if_ True f = f
if_ False _ = return ()
main = do
args <- getArgs
if_ (length args > 0)
(print args)
Strictly speaking that generalizes to any functional context where a generic
value can be assigned to the else clause, but there don't tend to be that
many other such contexts. Does that answer the question?
Donn Cave, donn@drizzle.com