Boolean values: Difference between revisions

Content added Content deleted
(add Haskell)
Line 48: Line 48:
> if (bowlian) { "a" } else { "b" }
> if (bowlian) { "a" } else { "b" }
# value: "a"</lang>
# value: "a"</lang>

=={{header|Haskell}}==

The Haskell standard [http://haskell.org/haskellwiki/Prelude Prelude] defines a data type <code>Bool</code>, which has exactly two members:

<lang haskell>data Bool = False | True deriving (Eq, Ord, Enum, Read, Show, Bounded)</lang>

In addition to all the functionality of any other Haskell algebraic data type (e.g. [[pattern matching]]), and the specified derived typeclass instances (e.g. <code>False == False</code>, <code>succ False == True</code>, <code>(maxBound :: Bool) == True</code>, etc.), the built-in guard (“<code>|</code>”) and <code>if</code> syntaxes use Bool.

As with any other Haskell data type, there are no automatic conversions of other types to Bool.


=={{header|Java}}==
=={{header|Java}}==