summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-api/T10508_api.hs
blob: f2f5574222d5ecd7bdf0af0aa5ab930a10dd1dea (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
33
module Main where

import GHC.Driver.Session
import GHC
import qualified GHC.LanguageExtensions as LangExt

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` LangExt.ImplicitPrelude

    forM_ exprs $ \expr ->
      handleSourceError printException $ do
        dyn <- dynCompileExpr expr
        liftIO $ print dyn
  where
  exprs =
    [ ""
    , "(),()"
    , "()"
    , "\"test\""
    , unlines [ "[()]"
              , " :: [()]"
              ]
    ]