Haskell is a purely functional programming language. (That is, functional as opposed to imperative/procedural programming languages. C, Java, and Perl are imperative languages. Lisp, Scheme, Ocaml, and Erlang are functional languages.) Haskell is different from any language I've used before; it reminds me a bit of SQL.
The most popular Haskell implementation is GHC (Glasgow Haskell Compiler), which has three components:
{----------------------------------------------------------------------------
Comments
----------------------------------------------------------------------------}
-- This is a single line comment.
{- This is...
...a multi-line...
...comment -}
{----------------------------------------------------------------------------
Arithmetic
----------------------------------------------------------------------------}
2 + 2 -- Infix addition
(+) 2 2 -- Prefix addition; operator must be in parens
2 * (-3) -- Negative numbers need to be in parens to avoid ambiguity
{----------------------------------------------------------------------------
Functions
----------------------------------------------------------------------------}
-- Optional type signature declared before type definition:
thingy :: Int -> Int -> Int
-- A function definition:
thingy x y z = x * ( y - z )
-- Guards make choices in functions based on boolean expressions:
max :: Ord a => a -> a -> a
max x y
| x > y = x
| otherwise = y
{----------------------------------------------------------------------------
----------------------------------------------------------------------------}
© Paul Gorman