<?php include 'HEADER.php' ?>

<h1>Haskell notes</h1>

<p>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.</p>

<p>The most popular Haskell implementation is GHC (Glasgow Haskell Compiler), which has three components:</p>

<dl>
    <dt>ghc</dt> <dd>a Haskell compiler which generates a native binary</dd>
    <dt>ghci</dt> <dd>an interactive interpreter and debugger</dd>
    <dt>runghc</dt> <dd>run Haskell code as a script, without compiling it</dd>
</dl>

<pre>
{----------------------------------------------------------------------------
    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 <b>type signature</b> declared before type definition:
thingy :: Int -&gt; Int -&gt; Int
-- A <b>function definition</b>:
thingy x y z = x * ( y - z )

-- <b>Guards</b> make choices in functions based on boolean expressions:
max :: Ord a =&gt; a -&gt; a -&gt; a
max x y
    | x &gt; y = x
    | otherwise = y

{----------------------------------------------------------------------------
----------------------------------------------------------------------------}
</pre>


<h2>Links</h2>

<ul>
    <li><a href="http://www.haskell.org/">haskell.org</a></li>
    <li><a href="http://book.realworldhaskell.org/">Real Word Haskell</a> O'Reilly book</li>
    <li><a href="http://www.haskell.org/~pairwise/intro/intro.html">Haskell tutorial for C Programmers</a></li>
    <li><a href="http://cs.anu.edu.au/student/comp1100/haskell/tourofsyntax.html">Tour of the Haskell Syntax</a></li>
    <li><a href="http://www.haskell.org/haskellwiki/Learn_Haskell_in_10_minutes">Learn Haskell in 10 minutes</a></li>
</ul>

<?php include '../FOOTER.php' ?>
