Big patch. Finally generalized the Optimization by Substitution. Now can work automatically for any given type, just adding it to the list of optimizable types. Instances are generated by Template Haskell for the types listed. This solves #10.