Using Haskell "eval" to evaluate an entire module instead of a single value

I played with the eval function provided by the plugin package. It works great for evaluating a single function.

I am wondering if there is a way to introduce the whole module and evaluate the value from this module (but letting this value refer to other things in the module)

For example, right now I'm doing something like

x :: Int
  where 
    y = 2
    z = 3
    x = y+z

I would like to do something like

module Foo where
import Bar

x :: Int
x = y+z

y = 2 :: Int
z = 3 :: Int

where I then use "eval" in the string and somehow get xback.

I could use the plugins.load functions, but I really would like to be able to evaluate directoy from a string, instead of loading from an object or a temporary file.

+4

All Articles