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
590
Boulder Startup Week: What is functional programming?
puffnfresh
0
67
Other Decks in Programming
See All in Programming
TROCCOで実現するkintone+BigQueryによるオペレーション改善
ssxota
0
120
TipKitTips
ktcryomm
0
150
Agent Skills Workshop - AIへの頼み方を仕組み化する
gotalab555
13
7.7k
株式会社 Sun terras カンパニーデック
sunterras
0
1.9k
AI駆動開発の本音 〜Claude Code並列開発で見えたエンジニアの新しい役割〜
hisuzuya
4
460
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
1.4k
Go 1.26でのsliceのメモリアロケーション最適化 / Go 1.26 リリースパーティ #go126party
mazrean
1
330
CSC307 Lecture 12
javiergs
PRO
0
450
PostgreSQL を使った快適な go test 環境を求めて
otakakot
0
390
ぼくの開発環境2026
yuzneri
1
290
AI時代のソフトウェア開発でも「人が仕様を書く」から始めよう-医療IT現場での実践とこれから
koukimiura
0
130
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
220
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
280
Music & Morning Musume
bryan
47
7.1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
A better future with KSS
kneath
240
18k
What's in a price? How to price your products and services
michaelherold
247
13k
Faster Mobile Websites
deanohume
310
31k
Testing 201, or: Great Expectations
jmmastey
46
8.1k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
200
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.3k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
78
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