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
80
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
Kaigi on Railsに初参加したら、その日にLT登壇が決定した件について
tama50505
0
110
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
3
500
nekko cloudにおけるProxmox VE利用事例
irumaru
3
460
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
130
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
testcontainers のススメ
sgash708
1
130
非ブラウザランタイムとWeb標準 / Non-Browser Runtimes and Web Standards
petamoriken
0
280
良いユニットテストを書こう
mototakatsu
10
3.2k
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
300
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
380
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
CloudflareStack でRAGに入門
asahiiwm
0
130
Featured
See All Featured
Making Projects Easy
brettharned
116
6k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Mobile First: as difficult as doing things right
swwweet
222
9k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.1k
4 Signs Your Business is Dying
shpigford
182
21k
RailsConf 2023
tenderlove
29
940
Become a Pro
speakerdeck
PRO
26
5k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Automating Front-end Workflow
addyosmani
1366
200k
Done Done
chrislema
182
16k
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