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

Viewed 572

I've been toying with the the "eval" function provided by the plugins package. It is working great for evaluating a single function.

I'm wondering, is there a way to input an entire module, and evaluate a value from that module (but allowing the value to reference 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'd 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" on the string and somehow get x back.

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

0 Answers
Related