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
LambdaConf: Idris Workshop
Search
Brian McKenna
April 19, 2014
Programming
2
130
LambdaConf: Idris Workshop
Brian McKenna
April 19, 2014
Tweet
Share
More Decks by Brian McKenna
See All by Brian McKenna
Production PureScript
puffnfresh
0
110
PureScript
puffnfresh
2
580
Boulder Startup Week: What is functional programming?
puffnfresh
0
66
Other Decks in Programming
See All in Programming
Conquering Massive Traffic Spikes in Ruby Applications with Pitchfork
riseshia
0
160
NetworkXとGNNで学ぶグラフデータ分析入門〜複雑な関係性を解き明かすPythonの力〜
mhrtech
3
1.2k
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
190
Go Conference 2025: Goで体感するMultipath TCP ― Go 1.24 時代の MPTCP Listener を理解する
takehaya
8
1.6k
Back to the Future: Let me tell you about the ACP protocol
terhechte
0
140
CSC305 Lecture 04
javiergs
PRO
0
260
エンジニアとして高みを目指す、 利益を生み出す設計の考え方 / design-for-profit
minodriven
24
12k
CSC509 Lecture 04
javiergs
PRO
0
300
Your Perfect Project Setup for Angular @BASTA! 2025 in Mainz
manfredsteyer
PRO
0
150
アメ車でサンノゼを走ってきたよ!
s_shimotori
0
210
なぜあの開発者はDevRelに伴走し続けるのか / Why Does That Developer Keep Running Alongside DevRel?
nrslib
3
390
Serena MCPのすすめ
wadakatu
4
950
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6.1k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
850
A Tale of Four Properties
chriscoyier
160
23k
Faster Mobile Websites
deanohume
310
31k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
A Modern Web Designer's Workflow
chriscoyier
697
190k
The Language of Interfaces
destraynor
162
25k
Automating Front-end Workflow
addyosmani
1371
200k
Transcript
LEARN DEPENDENTLY- TYPED PROGRAMMING WITH IDRIS
WHO I AM
▸ @puffnfresh ▸ Tiny contributor to Idris (18 commits) ▸
Played with dependent types for 2 years ▸ Been doing Idris for 6 months
ASSUMPTIONS
▸ Small experience with Haskell ▸ Have an install of
Idris (can be tricky)
$ brew install ghc cabal-install $ cabal update $ cabal
install alex $ cabal install idris
None
OUTLINE
1. Overview of dependent types and Idris 2. Work through
exercises, I lead 3. Work through exercises, I help
MOTIVATION
Bad news: most software cannot be reasoned about — Paul
Phillips
▸ Curry-Howard; programs are proofs ▸ Let's make our proofs
interesting ▸ Therefore let's use a powerful type system
MISCONCEPTIONS
▸ Idris is harder than Haskell ▸ Dependent types are
hard
DEPENDENT TYPES EVERYTHING IS A TERM
isIdris : Bool isIdris = True one : Nat one
= if isIdris then S Z else Z StringList : Type StringList = if isIdris then List Char else Int
▸ Types and kinds are values in universes ▸ Types
can depend on values ▸ Free polymorphism, type constructors
the : (t : Type) -> (x : t) ->
t the _ a = a one : Nat one = the Nat Z
id1 : {t : Type} -> (x : t) ->
t id1 {t} a = a id2 : (x : t) -> t id2 a = a id3 : t -> t id3 a = a
Option : Type -> Type Option = Maybe
TOTALITY
$ idris --total $ idris --warnpartial %default total total plusOne
: Nat -> Nat plusOne Z = S Z plusOne (S n) = S (S n)
I am often asked ‘how do I implement a server
as a program in your terminating language?’ — Conor McBride
I reply that I do not: a server is a
coprogram in a language guaranteeing liveness — Conor McBride
▸ We always make progress ▸ Watch out for the
totality checker! ▸ Church-Rosser theorem ▸ Evaluation is really normalisation! ▸ Can still do it all!
EQUALITY
data (=) : a -> b -> Type where refl
: x = x x : 1 = 1 x = refl y : 1 + 1 = 2 y = refl
x : {a : Nat} -> a - a =
Z x {a=Z} = refl x {a=S k} = x {a=k} y : {a : Nat} -> a - a = Z y {a} = replace {P = \x => (a - x = Z)} (plusZeroRightNeutral a) (minusPlusZero a Z)
x : {a : Nat} -> a - a =
Z x = ?xproof xproof = proof intros rewrite (minusPlusZero a Z) rewrite (plusZeroRightNeutral a) trivial
▸ The problem of dependent types ▸ Values are unified
▸ Checked for syntactic/term equality
WHY IDRIS?
▸ LLVM, C, Java, JS backends ▸ FFI ▸ Lots
of syntactic sugar ▸ Tactic rewriting ▸ Allows more lying/cheating ▸ REPL, editor modes, doc tools
None
None
HOW TO IDRIS
▸ Idris Tutorial ▸ Idris library docs ▸ Idris library
source ▸ Beginning Haskell: a Project Based Approach
LET'S GO
▸ printf ▸ Equality proofs ▸ Verified algebra ▸ Vector
filtering
http://goo.gl/gfCJne