Skip to content

Instantly share code, notes, and snippets.

@co-dan
Last active December 18, 2015 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save co-dan/5699706 to your computer and use it in GitHub Desktop.
Save co-dan/5699706 to your computer and use it in GitHub Desktop.
import Language.Haskell.Interpreter
import MyModule
main = do
r <- runInterpreter interp
case r of
Left err -> print $ show err
Right res -> print res
interp :: Interpreter IntBox
interp = do
set [searchPath := ["."]]
loadModules ["*MyModule.hs"]
setTopLevelModules ["MyModule"]
interpret ("testIB") (as :: IntBox)
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, DeriveDataTypeable #-}
module MyModule where
import Data.Typeable
data IntBox = IB Int
deriving (Typeable, Show)
testIB = IB 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment