TODO:
- history of haskell
- haskell modules
- the fun parts
# Ruby version of quiksort
class Array
def quick_sort
return self if length <= 1
pivot = self[0]
less, greatereq = self[1..-1].partition { |x| x < pivot }
less.quick_sort + [pivot] + greatereq.quick_sort
end
end
-- Haskell version of quicksort
qsort [] = []
qsort (x:xs) = qsort [y | y <- xs, y < x] ++ [x] ++ qsort [y | y <- xs, y >= x]
Okay, it's not a fair comparison, but see more examples here: http://rosettacode.org/wiki/Sorting_algorithms/Quicksort#Haskell
Do notice that Haskell is generally shorter than other typed languages!
todo
Haskell is actually a simple language. Most of the ideas about the language will mostly be syntactic constructions derived from these concepts:
Haskell is a typed language, its types are:
- static
- strong
- inferred
Haskell is a functional language offering:
- purity: - given the same input, functions will always produce the same output (like mathematical functions)
- side-effect free programming: - a function's output is determined by its type
- laziness: - nothing is evaluated until it has to be evaluated
- higher order programming: - functions return functions and taking functions as input
Haskell programs typically have fewer bugs due to a few properties:
- Side-effect free programming: - no unintended consequences (i.e. side effects)
- Modularity: - Due to purity, functions can be versatily used across various programs and can always be expected perform the same.
- Strong types: - no dubious use of types ~= no core dumps
- Conciseness: - Programs are typically short.
- Memory Mangement: - The garbage collections allows you to worry about the correct problem: implementing the algorithm
- High level abstractions: - Haskell programs most often read exactly like the algorithm description
Possible topics include:
- Category theory:
- functors, monoids, and monads
- ADTs
- GADTs