mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-11 05:49:31 -06:00
+ Eliminated vairous ad-hoc coersion functions between specific monads (IO, Err, IOE, Check) in favor of more general lifting functions (liftIO, liftErr). + Generalized many basic monadic operations from specific monads to arbitrary monads in the appropriate class (MonadIO and/or ErrorMonad), thereby completely eliminating the need for lifting functions in lots of places. This can be considered a small step forward towards a cleaner compiler API and more malleable compiler code in general.
38 lines
1.2 KiB
Haskell
38 lines
1.2 KiB
Haskell
module Main where
|
|
|
|
import GFC
|
|
import GFI
|
|
import GF.Data.ErrM
|
|
import GF.Infra.Option
|
|
import GF.Infra.UseIO
|
|
import GF.Infra.BuildInfo (buildInfo)
|
|
import Paths_gf
|
|
|
|
import Data.Version
|
|
import System.Directory
|
|
import System.Environment (getArgs)
|
|
import System.Exit
|
|
import GF.System.Console (setConsoleEncoding)
|
|
|
|
main :: IO ()
|
|
main = do
|
|
setConsoleEncoding
|
|
args <- getArgs
|
|
case parseOptions args of
|
|
Ok (opts,files) -> do curr_dir <- getCurrentDirectory
|
|
lib_dir <- getLibraryDirectory opts
|
|
mainOpts (fixRelativeLibPaths curr_dir lib_dir opts) files
|
|
Bad err -> do ePutStrLn err
|
|
ePutStrLn "You may want to try --help."
|
|
exitFailure
|
|
|
|
mainOpts :: Options -> [FilePath] -> IO ()
|
|
mainOpts opts files =
|
|
case flag optMode opts of
|
|
ModeVersion -> putStrLn $ "Grammatical Framework (GF) version " ++ showVersion version ++ "\n" ++ buildInfo
|
|
ModeHelp -> putStrLn helpMessage
|
|
ModeInteractive -> mainGFI opts files
|
|
ModeRun -> mainRunGFI opts files
|
|
ModeServer port -> mainServerGFI opts port files
|
|
ModeCompiler -> mainGFC opts files
|