Added some theoretical, untested Haskell code.