____

____

any one

functions

____

____

In the past few days I've been working on a generalised version of Haskell, designed for program optimisation and transformation. I've also implemented the start of a Haskell optimiser, but in about 100 lines of Haskell, using this generalised form of Haskell.Generalised Haskell is very much like a normal Haskell Core language, with less restrictions in pattern matching. In normal Haskell you would write "map" as:> map f [] = []> map f (x:xs) = f x : map f xsWhich would be compiled into:> map f x = case x of[] -> [](x:xs) -> f x : map f xsThe rule for pattern matching is that you take the first rule that matches. Generalised Haskell relaxes this slightly to takerule that matches, but not necessarily in order. The second relaxation is that when pattern matching on the left hand side,can appear as patterns.For example, you can now define:> map id x = x> map f x= case x of[] -> [](x:xs) -> f x : map f xsNote that the "map id" case looks very much like GHC's Rules feature. The advantage for optimisation is that many activities can be encoding using these pattern matches - arity raising, specialisation, deforestation.I am still working on a tool that uses this technique for optimisation, but initial results look quite promising, while the code remains impressively short.