Branching with if and else in Haskell is straightforward, although it differs from imperative languages in some aspects.
Note that in Haskell, if-then-else is an expression that always returns a value. The else part is mandatory. For more complex branching, pattern matching or guards are often used.
To run the program:
In Haskell, there’s no direct equivalent to the ternary operator, but the if-then-else expression can be used inline for similar purposes.