module Scion
( ScionM
, liftIO, MonadIO
, module Scion
, module Scion.Session
, module Scion.Utils
, module Scion.Configure
) where
import Scion.Types
import Scion.Session
import Scion.Configure
import Scion.Utils
import GHC
import FastString ( fsLit )
import Outputable ( printSDoc, defaultErrStyle, ppr, (<+>), text )
import GHC.Paths ( libdir )
import Control.Monad ( forM_ )
runScion :: ScionM a -> IO a
runScion m = do
runGhc (Just libdir) $ do
dflags <- getSessionDynFlags
r <- liftIO $ mkSessionState dflags
setSessionDynFlags (initialScionDynFlags dflags)
unScionM m r
runScion' :: [String] -> ScionM a -> IO a
runScion' static_flags act = do
let fname = fsLit "<api-client>"
lflags = [ L (mkSrcSpan (mkSrcLoc fname line 0) (mkSrcLoc fname line (length s))) s
| (s,line) <- zip static_flags [1..] ]
(_leftovers, warnings) <- parseStaticFlags lflags
forM_ warnings $ \(L region msg) ->
printSDoc (ppr region <+> text msg) defaultErrStyle
runScion act