Haskell: Programming Language
Haskell: Programming Language
programming language
Haskell is…
Concurrency
– The #1 on Language Shootout for threading
– All non-I/O code is concurrent by default
– (mutations are handled as I/O code)
Readability
– No parentheses or commas
– Higher-order functions reduce lines-of-code
– (no syntax as a reminder of context)
Haskell - namespaces
life = 42 :: Int
life :: Int
life = 42
Haskell - types
“Hello” :: String
length :: [a] -> Int
floor :: Float -> Int
map :: (a -> b) -> [a] -> [b]
42 :: Int
(+) :: Int -> Int -> Int
42 :: Num a => a
(+) :: Num a => a -> a -> a
Haskell - type system
main = interact
-- GNU tac
(unlines . reverse . lines)
-- UNIX echo
main = do
args <- getArgs
case args of
"-n":a -> putStr (unwords a)
a -> putStrLn (unwords a)
version control system
Darcs - overview
Interactive “pull”
– You chose what patches to download
Interactive “push”
– You chose what patches to commit externally
Interactive “record”
– You chose what files to commit locally
Parsec
parser library
Parsec - combinators
sepBy :: Parser a -> Parser s -> Parser [a] -- ... , ... , ...
sepBy1 :: Parser a -> Parser s -> Parser [a]
endBy :: Parser a -> Parser s -> Parser [a] -- ... ; ... ; ... ;
endBy1 :: Parser a -> Parser s -> Parser [a]
string = between
(char ‘"’)
(char ‘"’)
(many anyChar)
lisp = number
<|> string
<|> identifier
<|> parens $ many $ lexeme lisp
xmonad
import XMonad
import System.Exit
import qualified XMonad.StackSet as W
import qualified Data.Map as M
defaults = defaultConfig {
keys = myKeys,
mouseBindings = myMouseBindings,
terminal = "xterm"}
Extensible
– Fully dynamic application (hs-plugins)
– All state is serialized and reloaded
Customizable
– yi --as=vim (for vim key bindings)
– yi --as=emacs (for emacs key bindings)
Yi - structure
Thank You