Miscellaneous Haskell hacking, mostly mathematical