A rewrite of Ledger's core mathematical concepts in Haskell