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
77
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
350
Machine learning: boldly going where Twitter's APIs don't
metabroadcast
0
120
monitoring: it gets better
metabroadcast
1
560
The ABCs of MetaBroadcast APIs
metabroadcast
0
170
APIs for app developers
metabroadcast
1
140
Polishing Varnish
metabroadcast
0
820
Atlas - 3.0 to 4.0
metabroadcast
0
240
Atlas - owl vs deer
metabroadcast
0
240
Storm - an overview
metabroadcast
0
120
Other Decks in Programming
See All in Programming
イマのCSSでできる インタラクション最前線 + CSS最新情報
clockmaker
5
3.1k
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.2k
イベント駆動で成長して委員会
happymana
1
340
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
680
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
120
Amazon Qを使ってIaCを触ろう!
maruto
0
420
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.3k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
110
romajip: 日本の住所CSVデータを活用した英語住所変換ライブラリを作った話
sangunkang
0
400
Tauriでネイティブアプリを作りたい
tsucchinoko
0
380
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
130
我々のデザインシステムは Chakra v3 にアップデートします
shunya078
2
310
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
850
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
Practical Orchestrator
shlominoach
186
10k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
Fireside Chat
paigeccino
34
3k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Done Done
chrislema
181
16k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Faster Mobile Websites
deanohume
305
30k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Building Applications with DynamoDB
mza
90
6.1k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
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