[Haskell-cafe] Re: Tips of Conditional Expression

Christian Maeder Christian.Maeder at dfki.de
Fri Feb 22 09:04:30 EST 2008

> I know the following:
> [1] That the general form of conditional expression is: if
> *Boolean_expression* then /exp1/ else /exp2
> /[2] That a conditional expression must always have both a then and an
> else expression.
> [3] That both /exp1/ and /exp2/ must have the same type, which is the
> type of the entire conditional expression.
> [4] That /exp1/ must be <true-value> and /exp2/ must be <false-value>
> Reference: Discrete Mathematics Using Computer by John O'Donnell and et
> al. (Second Edition)
> My question: Is it possible that exp1 and exp 2  be different function
> calls of another functions (separately) elsewhere within the same program?
> Note: My Boolean_expression is Boolean
>          My /exp1/ is a function call elsewhere within the same program
> (more like a subroutine)
>          My /exp2/ is another function call also elsewhere within the
> same program.

I'm not sure what you're asking, but exp1 and exp2 may have (the same)
function type:

if <cond> then map else filter :: (Bool -> Bool) -> [Bool] -> [Bool]

HTH Christian

More information about the Haskell-Cafe mailing list