Is it possible to program and check invariants in Haskell?
The following is a stunt, but it’s quite a safe stunt so do try it at home. It uses some of the entertaining new toys to bake order invariants into mergeSort. {-# LANGUAGE GADTs, PolyKinds, KindSignatures, MultiParamTypeClasses, FlexibleInstances, RankNTypes, FlexibleContexts #-} I’ll have natural numbers, just to keep things simple. data Nat = Z | … Read more