Evaluation of Haskell Statements/Expressions using GHC API

Posted by Cetin Sert on Stack Overflow See other posts from Stack Overflow or by Cetin Sert
Published on 2010-03-16T00:12:38Z Indexed on 2010/03/16 0:19 UTC
Read the original article Hit count: 702

Filed under:
|
|
|
|

For a tool I'm writing ( http://hackage.haskell.org/package/explore ) I need a way to read haskell function definitions at run-time, apply them to values from my tool and retrieve the results of their application.

Can anyone give me a very basic example using GHC (6.10.4 or 6.12.1) API?

example function definition to be read from a file at run-time:

f x = 10**(((4/1102)*x)-1)

expected program output

--mapM_ print $ map f [428, 410, 389]
3.577165388142748
3.077536885227335
2.5821307011665815

© Stack Overflow or respective owner

Related posts about haskell

Related posts about ghc