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
100
PureScript
puffnfresh
2
580
Boulder Startup Week: What is functional programming?
puffnfresh
0
64
Other Decks in Programming
See All in Programming
The State of Fluid (2025)
s2b
0
170
大規模FlutterプロジェクトのCI実行時間を約8割削減した話
teamlab
PRO
0
480
Constant integer division faster than compiler-generated code
herumi
2
670
What's new in Adaptive Android development
fornewid
0
140
管你要 trace 什麼、bpftrace 用下去就對了 — COSCUP 2025
shunghsiyu
0
420
書き捨てではなく継続開発可能なコードをAIコーディングエージェントで書くために意識していること
shuyakinjo
1
280
実践 Dev Containers × Claude Code
touyu
1
210
ライブ配信サービスの インフラのジレンマ -マルチクラウドに至ったワケ-
mirrativ
1
240
tool ディレクティブを導入してみた感想
sgash708
1
140
React 使いじゃなくても知っておきたい教養としての React
oukayuka
18
5.7k
ゲームの物理
fadis
5
1.2k
No Install CMS戦略 〜 5年先を見据えたフロントエンド開発を考える / no_install_cms
rdlabo
0
480
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.8k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Code Review Best Practice
trishagee
69
19k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
131
19k
Faster Mobile Websites
deanohume
309
31k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Docker and Python
trallard
45
3.5k
A designer walks into a library…
pauljervisheath
207
24k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Optimizing for Happiness
mojombo
379
70k
A better future with KSS
kneath
239
17k
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