Arnaud Spiwack
{-# LANGUAGE LinearTypes #-}
f :: a ⊸ b
f x = … -- consumes x exactly onceSince GHC 9.0
id x = x✓
linear
dup x = (x,x)✗
not linear
swap (x,y) = (y,x)✓
linear
forget x = ()✗
not linear
f (Left x) = x
f (Right y) = y✓
linear
✓
linear
✗
not linear
h x b = case b of
True -> x
False -> xg z = case z of
Left x -> x
Right y -> yk x b = case b of
True -> x
False -> ()✓
linear
f x = dup x✓
linear
✗
not linear
h u = u 0g x = id (id x)k u = u (u 0)✓
linear
✗
not linear
Coercion stuff
Newtypes
Type families
GADTs
The same
Doesn't return a new copy of ys
show :: Show a => a -> StringA constraint
Prolog-like language
Constrained
With paramodulation
Idea: teach constraints linear logic
https://slides.com/aspiwack/pps2021
https://www.tweag.io/blog/tags/linear-types/
https://arxiv.org/abs/2103.06127