[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

code generation for other languages



I'm writing a haskell program that generates C++ code based upon some
haskell data structures. At the moment, the code is somewhat ugly with
lots of stuff like

	mutatorDef structName (name,vtype) = 
	    "inline void\n" ++
	    structName ++ "::" ++ (mutatorName name) ++
	    "( " ++ (cppParamType vtype) ++ " v ) {\n" ++
	    "    " ++ (storageName name) ++ " = v;\n" ++
	    "}\n\n"

All those ++ operators working on raw strings bug me, and manually
getting the indentation correct is a pain. Is there a more
functional approach to generating source code? I thought this could be 
a common enough task that there could be a library, but a perusal of
haskell.org didn't seem to show anything relevant.

Thanks,
Tim