Glasgow Haskell Compiler (GHC) - The compiler for Haskell. Cabal - Package description format. Stack - Package management tool.
brew update # upgrade HomeBrew brew install haskell-stack # install package management tool Stack stack new # download Haskell runtime environment
M-x package-refresh-contents M-x package-install RET haskell-mode
(setq haskell-program-name "GHCI_PATH")
putStrLn "Hello World" 92 `div` 13
let f x = 1 + x -- Same as define ~f~ in a file and load it using :l f 2 -- 3
let double'Small'Num x = (if x > 100 then x else 2 * x) + 1 double'Small'Num 101 -- 102
1 : [2,3] ++ [4,5] ++ [] -- [1,2,3,4,5] ('H' : "ello" ++ " " ++ "World") !! 1 -- 'e' [3,2,1] <= [3,2,2] -- True let l = [1,2,3,4] (tail l) ++ [head l] -- [4,1,2,3] (last l) : (init l) -- [4,1,2,3] length l -- 4 null [] -- True reverse l -- [4,3,2,1] take 2 l -- [1,2] drop 2 l -- [3,4] maximum l -- 4 sum l -- 10 product l -- 24 5 `elem` l -- False
[1..4] -- [1,2,3,4] ['a'..'d'] -- "abcd" [1,3..7] -- [1,3,5,7] [13,26..4*13] -- [13,26,39,52]
[ x*2 | x<-[1..3], x/=2 ] -- [2,6] let xxs = [[1..3], [2..4], [3..5]] [[x | x <- xs, even x] | xs <- xxs] -- [[2], [2,4], [4]] [x+y | x <- [1..3], y <- [2..5]] -- [3,4,5,6,4,5,6,7,5,6,7,8]