packages feed

ftshell-0.2: src/Settings.hs



-- Application settings. They can be changed (partly) by command line options.
module Settings where



import Paths_ftshell (getDataFileName, version)

import Data.Version (showVersion)
import Language.Haskell.FreeTheorems (Parsed)
import Language.Haskell.FreeTheorems.Syntax (Declaration)

-- Import the parsers used by the shell.
import qualified Language.Haskell.FreeTheorems.Parser.Haskell98 as Haskell98
import qualified Language.Haskell.FreeTheorems.Parser.Hsx as Hsx

-- Import the backends used by the shell.
import System.Console.Shell.Backend (ShellBackend)
import System.Console.Shell.Backend.Readline (readlineBackend)



-- The filename of the file in which the basic declarations reside.
-- This file is always loaded on startup.
basicDeclarationsFileName = "declarations.hs"



-- A structure containing all application settings.
-- Note that this structure is partly reflected by 'ShellState'.
data Settings = Settings
  { parser           :: String -> Parsed [Declaration]
  , parserName       :: String
  , backend          :: ShellBackend ()
  , backendName      :: String
  , insteadOfShell   :: Maybe PrintSomething
  , prelude          :: Maybe FilePath
  , inputFiles       :: [String]
  }



-- Initialize the settings.
-- The command line options are modifying these settings afterwards.
initialSettings = do
  declFileName <- getDataFileName basicDeclarationsFileName
  return $ Settings
    { parser           = Hsx.parse
    , parserName       = "Haskell parser with extensions based on "
                         ++ "`haskell-src-exts'"
--    { parser           = Haskell98.parse
--    , parserName       = "Haskell98 parser based on `haskell-src'"
    , backend          = readlineBackend
    , backendName      = "readline-based backend"
    , insteadOfShell   = Nothing
    , prelude          = Just declFileName
    , inputFiles       = []
    }



-- Actions to be done instead of running the shell.
data PrintSomething
  = PrintHelp       -- Print the available command line options.
  | PrintVersion    -- Print the application version.