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
76
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
550
The ABCs of MetaBroadcast APIs
metabroadcast
0
160
APIs for app developers
metabroadcast
1
140
Polishing Varnish
metabroadcast
0
810
Atlas - 3.0 to 4.0
metabroadcast
0
230
Atlas - owl vs deer
metabroadcast
0
230
Storm - an overview
metabroadcast
0
110
Other Decks in Programming
See All in Programming
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
1.1k
新宿ダンジョンを可視化してみた
satoshi7190
3
400
Going beyond Apache Parquet's default settings
xhochy
0
130
Introducing Kotlin Multiplatform in an existing mobile app - Workshop Edition | AndroidMakers Paris
prof18
0
160
Elm 0.19.0 Changes
bkuhlmann
0
510
GraphQLサーバの構成要素を整理する #ハッカー鮨 #tsukijigraphql / graphql server technology selection
izumin5210
4
910
スキーマ駆動開発による品質とスピードの両立 - 私達は何故、スキーマを書くのか
kentaroutakeda
0
180
Goのエラースタックトレースの歴史と今後
sonatard
10
1.8k
Let's learn code review
riofujimon
2
600
Netty Chicago Java User Group 2024-04-17
sullis
0
210
Elm Form Validation
bkuhlmann
0
520
Kotlin Multiplatform at Stable and Beyond (Android Makers 2024)
zsmb
0
520
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
117
18k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
242
1.2M
Building Effective Engineering Teams - LeadDev
addyosmani
32
1.9k
The Art of Programming - Codeland 2020
erikaheidi
43
12k
Large-scale JavaScript Application Architecture
addyosmani
504
110k
What’s in a name? Adding method to the madness
productmarketing
PRO
17
2.7k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.9k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
245
20k
Fashionably flexible responsive web design (full day workshop)
malarkey
398
65k
Making the Leap to Tech Lead
cromwellryan
125
8.5k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
9
1.3k
Designing for Performance
lara
601
67k
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