- Riff on https://www.reddit.com/r/haskell/comments/8qn0wr/safe_api_design_with_ghosts_of_departed_proofs/
- reddit thread: https://www.reddit.com/r/haskell/comments/dlzc46/ghosts_via_departed_proofs_experimenting/
Ghosts of Departed Proofs introduces sortBy
. It sorts using a comparison function a -> a -> Ordering
named "comp
". The name is then recorded in the return type: "this list is sorted by comp
"!
type Cmp :: Type -> Type
type Cmp a = (a -> a -> Ordering)
sortBy :: Cmp a~~comp -> [a] -> SortedBy comp [a]