Common types

The Haskell standard library (a package called base) provides various basic data types. Here we demonstrate only a few of them.

main =
  do

Strings can be joined together with ++.

    putStrLn ("hask" ++ "ell")

Integers are unbounded whole numbers.

    putStrLn ("1+1 = " ++ show (1 + 1))

Floating-point numbers can be fractional.

    putStrLn ("7.0/3.0 = " ++ show (7.0 / 3.0))

Booleans have the standard and, or, and not operations.

    putStrLn (show (True && False))
    putStrLn (show (True || False))
    putStrLn (show (not True))
$ runhaskell common-types.hs
haskell
1+1 = 2

Operations on floating-point numbers are subject to rounding error.

7.0/3.0 = 2.3333333333333335
False
True
False

Next: