0
head
and tail
are Safeaverage
List
s Elementsmax
Functionmax
type (I)max
type (II)max
type (III)
LiquidHaskell: Liquid Types for Haskell
λ> let average xs = sum xs `div` length xs
λ> average [100, 202, 300]
2
λ> average []
*** Exception: divide by zero
λ> head "compose"
'c'
λ> head []
*** Exception: Prelude.head: empty list
λ> sort [42, 5, 3, 1]
[5, 3]
λ> (incr . incr) 40
0
To prevent wider class of errors
To enforce program specific properties
Diverse Code Bases
10KLoc / 56 Modules
Memory Safety, Termination, Functional Correctness
Inference is Crucial
Specifications: 1 / 10 LOC (ok)
Compile Time: 1s / 10 LOC (not ok!)
Library | LOC | Specs | Time |
---|---|---|---|
XMonad.StackSet |
256 | 74 | 27s |
Data.List |
814 | 46 | 26s |
Data.Set.Splay |
149 | 27 | 27s |
Data.Vector.Algorithms |
1219 | 76 | 89s |
HsColour |
1047 | 19 | 196s |
Data.Map.Base |
1396 | 125 | 174s |
Data.Text |
3128 | 305 | 499s |
Data.Bytestring |
3505 | 307 | 294s |
Total | 11512 | 977 | 1336s |
Refinement Types: Automated Dependent Typing via SMT
Properties: | Predicates + Types |
Proofs: | SMT Solvers + Subtyping |
Inference: | Abstract Interpretation + Hindley-Milner |
cabal install liquidhaskell
http://www.refinement-types.org
online demo @ http://goto.ucsd.edu/liquidhaskell