blob: afe8e50e7389b7a5a8cf99ea08277329a170d5c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
module Main where
import DynFlags
import GHC
import Control.Monad (forM_)
import Control.Monad.IO.Class (liftIO)
import System.Environment (getArgs)
main :: IO ()
main = do
[libdir] <- getArgs
runGhc (Just libdir) $ do
dflags <- getSessionDynFlags
setSessionDynFlags $ dflags
`gopt_unset` Opt_ImplicitImportQualified
`xopt_unset` Opt_ImplicitPrelude
forM_ exprs $ \expr ->
handleSourceError printException $ do
dyn <- dynCompileExpr expr
liftIO $ print dyn
where
exprs =
[ ""
, "(),()"
, "()"
, "\"test\""
, unlines [ "[()]"
, " :: [()]"
]
]
|