0
size
returns positive valuesavg
head
and tail
are Safeaverage
map
init
init'
insert
List
s ElementsList
keys
Map
eval
create
: Allocate and Fill a ByteString
unsafeTake
: Extract prefix of size n
unpack
: Convert ByteString
into List of Char
Lets define our own List
data type:
Measure
Haskell function with a single equation per constructor
Measure
Strengthens type of data constructor
data List a where
Emp :: {v:List a | length v = 0}
(:::) :: x:a -> xs:List a
-> {v:List a | length v = 1 + length xs}
Fear head
and tail
no more!
Q: Write types for head
and tail
that verify impossible
.
A convenient type alias
Fold or Reduce f
over any list using seed acc
Fold or Reduce f
over non-empty list using first element as seed
average
Q: What is a safe input type for average'
?
Make illegal states unrepresentable
Legal Values: Lists of 12
elements, e.g.
"jan" ::: "feb" ::: ... ::: "dec" ::: Emp"
Refine Type to Legal Values
Lists Of A Given Size
Make illegal states unrepresentable
map
Q: Can you fix map
to verify tempAverage
?
init
Q: Can you fix the type of init
so that sanDiegoTemp
is accepted?
init'
Q: For bonus points, fix init'
so sanDiegoTemp'
is accepted?
Next: Case Studies