Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Haskell - A brief introduction
Search
MetaBroadcast
June 13, 2012
Programming
0
88
Haskell - A brief introduction
Talk given by Fred van den Driessche on 13-06-2012 at MetaBroadcast.
MetaBroadcast
June 13, 2012
Tweet
Share
More Decks by MetaBroadcast
See All by MetaBroadcast
PhotoGlut
metabroadcast
2
360
Machine learning: boldly going where Twitter's APIs don't
metabroadcast
0
130
monitoring: it gets better
metabroadcast
1
570
The ABCs of MetaBroadcast APIs
metabroadcast
0
200
APIs for app developers
metabroadcast
1
150
Polishing Varnish
metabroadcast
0
830
Atlas - 3.0 to 4.0
metabroadcast
0
240
Atlas - owl vs deer
metabroadcast
0
250
Storm - an overview
metabroadcast
0
130
Other Decks in Programming
See All in Programming
Namespace and Its Future
tagomoris
6
700
GitHubとGitLabとAWS CodePipelineでCI/CDを組み比べてみた
satoshi256kbyte
4
180
🔨 小さなビルドシステムを作る
momeemt
3
670
オープンセミナー2025@広島「君はどこで動かすか?」アンケート結果
satoshi256kbyte
0
260
1から理解するWeb Push
dora1998
7
1.8k
@Environment(\.keyPath)那么好我不允许你们不知道! / atEnvironment keyPath is so good and you should know it!
lovee
0
110
ユーザーも開発者も悩ませない TV アプリ開発 ~Compose の内部実装から学ぶフォーカス制御~
taked137
0
120
OSS開発者という働き方
andpad
5
1.7k
Vue・React マルチプロダクト開発を支える Vite
andpad
0
110
Ruby×iOSアプリ開発 ~共に歩んだエコシステムの物語~
temoki
0
270
AIでLINEスタンプを作ってみた
eycjur
1
230
Protocol Buffersの型を超えて拡張性を得る / Beyond Protocol Buffers Types Achieving Extensibility
linyows
0
110
Featured
See All Featured
The Cult of Friendly URLs
andyhume
79
6.6k
Code Review Best Practice
trishagee
70
19k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.1k
Imperfection Machines: The Place of Print at Facebook
scottboms
268
13k
Optimizing for Happiness
mojombo
379
70k
Being A Developer After 40
akosma
90
590k
Side Projects
sachag
455
43k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
61k
What's in a price? How to price your products and services
michaelherold
246
12k
Transcript
Haskell A Brief Introduction
Pure Functional Lists Lazy • • •
Built-in Types Numbers: 1, 1.234 Booleans: True, False Characters/Strings: 'a',
"asdf" Lists: [1,2,3] Tuples:("jim", 25) • • • • •
Functions double x = 2 * x > double 5
10
Control max x y = if x > y then
x else y max x y | x > y = x | otherwise y
Lists [] 1 : [2, 3] = [1, 2, 3]
[1, 2] ++ [3, 4] = [1, 2, 3, 4] head [1, 2, 3] = 1 tail [1, 2, 3] = [2, 3]g • • • • •
Pattern Matching dblAll [] = [] dblAll (x:xs)= double x
: dblAll xs
Higher-order functions > map double [1, 2, 3] [2, 4,
6] map f [] = [] map f (x:xs) = f x : map f xs
Function Types > :t double double :: Num a =>
a -> a > :t (*) (*) :: Num a => a -> a -> a > :t map map :: (a -> b) -> [a] -> [b]
Currying > :t (*) (*) :: Num a => a
-> a -> a > :t (2*) (2*) :: Num a => a -> a double = 2* dblAll = map (2*)
Data Types data Bool = True | False data Maybe
a = Just a | Nothing data Either a b = Left a | Right b data Tree a = Empty | Node a (Tree a) (Tree b ) • • • •
yesOrNo True = "yes" yesOrNo False = "no" traverse Empty
= [] traverse (Node v l r) = (traverse l) ++ v : traverse r
Laziness fib c n = c : fib n (c
+ n) > fib 0 1 [0, 1, 1, 2, 3, 5, 8, 13, 21 ... > take 5 (fib 0 1) [0, 1, 1, 2, 3]
Laziness > (fib 0 1) !! 900 54877108839480000051413673948383714443800