(* 15-814 Fall 2025 *) (* Lec 19: Linear Functional Programming *) type nat[k] = +{'zero : 1, 'succ : } type list[m k] = +{'nil : 1, 'cons : * } mode U structural :> A L mode A affine :> L mode L linear decl append (l1 : list[L L]) (l2 : list[L L]) : list[L L] defn append l1 l2 = match l1 with | 'nil () => l2 | 'cons (, ) => 'cons (, ) decl length (l : list[L A]) : nat[L] defn length l = match l with | 'nil () => 'zero () | 'cons (, ) => 'succ decl map (f : [U] up[L] (nat[L] -> nat[L])) (l : list[L L]) : list[L L] defn map f l = match l with | 'nil () => 'nil () | 'cons (, ) => 'cons (, )