added const body again
This commit is contained in:
parent
e42c775135
commit
072f2206e6
1 changed files with 54 additions and 43 deletions
97
src/Main.hs
97
src/Main.hs
|
|
@ -2,37 +2,46 @@
|
||||||
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import AnnForall (annotateForall)
|
import AnnForall (annotateForall)
|
||||||
import Codegen.Codegen (generateCode)
|
import Codegen.Codegen (generateCode)
|
||||||
import Compiler (compile)
|
import Compiler (compile)
|
||||||
import Control.Monad (when, (<=<))
|
import Control.Monad (when, (<=<))
|
||||||
import Data.List.Extra (isSuffixOf)
|
import Data.List.Extra (isSuffixOf)
|
||||||
import Data.Maybe (fromJust, isNothing)
|
import Data.Maybe (fromJust, isNothing)
|
||||||
import Desugar.Desugar (desugar)
|
import Desugar.Desugar (desugar)
|
||||||
import GHC.IO.Handle.Text (hPutStrLn)
|
import GHC.IO.Handle.Text (hPutStrLn)
|
||||||
import Grammar.ErrM (Err)
|
import Grammar.ErrM (Err)
|
||||||
import Grammar.Layout (resolveLayout)
|
import Grammar.Layout (resolveLayout)
|
||||||
import Grammar.Par (myLexer, pProgram)
|
import Grammar.Par (myLexer, pProgram)
|
||||||
import Grammar.Print (Print, printTree)
|
import Grammar.Print (Print, printTree)
|
||||||
import LambdaLifter (lambdaLift)
|
import LambdaLifter (lambdaLift)
|
||||||
import Monomorphizer.Monomorphizer (monomorphize)
|
import Monomorphizer.Monomorphizer (monomorphize)
|
||||||
import Renamer.Renamer (rename)
|
import Renamer.Renamer (rename)
|
||||||
import ReportForall (reportForall)
|
import ReportForall (reportForall)
|
||||||
import System.Console.GetOpt (ArgDescr (NoArg, ReqArg),
|
import System.Console.GetOpt (
|
||||||
ArgOrder (RequireOrder),
|
ArgDescr (NoArg, ReqArg),
|
||||||
OptDescr (Option), getOpt,
|
ArgOrder (RequireOrder),
|
||||||
usageInfo)
|
OptDescr (Option),
|
||||||
import System.Directory (createDirectory, doesPathExist,
|
getOpt,
|
||||||
getDirectoryContents,
|
usageInfo,
|
||||||
removeDirectoryRecursive,
|
)
|
||||||
setCurrentDirectory)
|
import System.Directory (
|
||||||
import System.Environment (getArgs)
|
createDirectory,
|
||||||
import System.Exit (ExitCode (ExitFailure),
|
doesPathExist,
|
||||||
exitFailure, exitSuccess,
|
getDirectoryContents,
|
||||||
exitWith)
|
removeDirectoryRecursive,
|
||||||
import System.IO (stderr)
|
setCurrentDirectory,
|
||||||
import System.Process (spawnCommand, waitForProcess)
|
)
|
||||||
import TypeChecker.TypeChecker (TypeChecker (Bi, Hm), typecheck)
|
import System.Environment (getArgs)
|
||||||
|
import System.Exit (
|
||||||
|
ExitCode (ExitFailure),
|
||||||
|
exitFailure,
|
||||||
|
exitSuccess,
|
||||||
|
exitWith,
|
||||||
|
)
|
||||||
|
import System.IO (stderr)
|
||||||
|
import System.Process (spawnCommand, waitForProcess)
|
||||||
|
import TypeChecker.TypeChecker (TypeChecker (Bi, Hm), typecheck)
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = getArgs >>= parseArgs >>= uncurry main'
|
main = getArgs >>= parseArgs >>= uncurry main'
|
||||||
|
|
@ -79,11 +88,11 @@ chooseTypechecker s options = options{typechecker = tc}
|
||||||
tc = case s of
|
tc = case s of
|
||||||
"hm" -> pure Hm
|
"hm" -> pure Hm
|
||||||
"bi" -> pure Bi
|
"bi" -> pure Bi
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
data Options = Options
|
data Options = Options
|
||||||
{ help :: Bool
|
{ help :: Bool
|
||||||
, debug :: Bool
|
, debug :: Bool
|
||||||
, typechecker :: Maybe TypeChecker
|
, typechecker :: Maybe TypeChecker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,12 +167,14 @@ fromErr :: Err a -> IO a
|
||||||
fromErr = either (\s -> printToErr s >> exitFailure) pure
|
fromErr = either (\s -> printToErr s >> exitFailure) pure
|
||||||
|
|
||||||
prelude :: String
|
prelude :: String
|
||||||
prelude = unlines
|
prelude =
|
||||||
[ "\n"
|
unlines
|
||||||
, "const : a -> b -> a"
|
[ "\n"
|
||||||
, "data Bool () where"
|
, "const : a -> b -> a"
|
||||||
, " False : Bool ()"
|
, "const x y = x"
|
||||||
, " True : Bool ()"
|
, "data Bool () where"
|
||||||
, "lt : Int -> Int -> Bool ()"
|
, " False : Bool ()"
|
||||||
, "lt x y = const True (x + y)"
|
, " True : Bool ()"
|
||||||
]
|
, "lt : Int -> Int -> Bool ()"
|
||||||
|
, "lt x y = const True (x + y)"
|
||||||
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue