[Haskell] ANNOUNCE: HFusion
facundominguez at gmail.com
Fri Apr 29 23:23:56 CEST 2011
I'm pleased to announce the first release of HFusion as a library.
HFusion is a tool which transforms a subset of Haskell programs by
applying fusion techniques based on hylomorphism, a program scheme by
means of which it is possible to express a wide class of recursive
functions. Hylomorphisms are automatically derived from user supplied
definitions . Related work includes [2,3,4,5].
The HFusion implementation allows to handle some interesting cases like:
* primitive recursion
* mutual recursion
* recursion over multiple arguments
* recursion based on regular functors
The library is not particularly solid yet, but it may be of use to
people interested in program transformations and certainly it would
benefit from community feedback. Requests for fixes, explanations and
improvements are more than welcome.
======= Use example =======
fuseDefinitions :: String -> Either FusionError String
fuseDefinitions sourceCode = runFusionState newVarGen$
-- Parse input with a Haskell parser.
parseResult2FusionState (Language.Haskell.Parser.parseModule sourceCode)
-- Convert the haskell AST to the AST used by HFusion.
-- Derive hylomorphisms for the definitions in the program.
>>= lift . fmap snd . deriveHylos
-- Fuse functions "zip" and "filter", which are expected
-- to be defined in the sourceCode parameter, composing
-- "filter" on the second argument of "zip" and naming "zf"
-- the resulting recursive definition.
>>= fuse "zip" 2 "filter" ["zf"]
-- Translate the result from HFusion AST to Haskell source code.
>>= return . hsSyn2HsSourceCode
main = do
cs <- readFile "examples.hs"
putStr$ either (("There was an error: "++) . show) id$ fuseDefinitions cs
 P. Johann and E. Visser. Warm fusion in Stratego: A case study in
generation of program transformation systems. Annals of Mathematics
and A.I., 29(1-4):1–34, 2000.
 T. Yokoyama, Z. Hu, and M. Takeichi. Calculation rules for
warming-up in fusion transformation. In Trends in Func. Programming,
pages 399–41, 2005.
 O. Chitil. Type-Inference Based Deforestation of Functional
Programs. PhD thesis, RWTH Aachen, October 2000.
 L. Németh. Catamorphism-Based Program Transformations for
Non-Strict Functional Languages. PhD thesis, Glasgow University, 2000.
More information about the Haskell