Get all of the Haskell files compiling with the new type checker.

Does not actually work, undefined is used in some places as a
stopgap measure.
This commit is contained in:
Evan Czaplicki 2013-07-11 12:48:37 +02:00
parent abaa76943e
commit cb914d91ff
5 changed files with 59 additions and 41 deletions

View file

@ -34,14 +34,16 @@ Library
Language.Elm.Quasi Language.Elm.Quasi
Hs-Source-Dirs: compiler Hs-Source-Dirs: compiler
other-modules: Unique, other-modules: Unique,
SourceSyntax.Helpers,
SourceSyntax.Location,
SourceSyntax.Literal,
SourceSyntax.Pattern,
SourceSyntax.Expression,
SourceSyntax.Declaration, SourceSyntax.Declaration,
SourceSyntax.Expression,
SourceSyntax.Everything,
SourceSyntax.Helpers,
SourceSyntax.Literal,
SourceSyntax.Location,
SourceSyntax.Module, SourceSyntax.Module,
SourceSyntax.Rename SourceSyntax.Pattern,
SourceSyntax.Rename,
SourceSyntax.Type,
Generate.JavaScript, Generate.JavaScript,
Generate.Noscript, Generate.Noscript,
Generate.Html, Generate.Html,
@ -52,21 +54,24 @@ Library
Metadata.LoadLibraries, Metadata.LoadLibraries,
Initialize, Initialize,
Parse.Binop, Parse.Binop,
Parse.Declaration,
Parse.Expression, Parse.Expression,
Parse.Foreign,
Parse.Helpers, Parse.Helpers,
Parse.Literal, Parse.Literal,
Parse.Module, Parse.Module,
Parse.Parser, Parse.Parser,
Parse.Pattern, Parse.Pattern,
Parse.Type, Parse.Type,
Types.Alias, Type.Constrain.Declaration,
Types.Types, Type.Constrain.Expression,
Types.Constrain, Type.Constrain.Literal,
Types.Hints, Type.Constrain.Pattern,
Types.Solver, Type.Environment,
Types.Substitutions, Type.Fragment,
Types.Unify, Type.Solve,
Type.State,
Type.Type,
Type.Unify,
Paths_Elm Paths_Elm
Build-depends: base >=4.2 && <5, Build-depends: base >=4.2 && <5,
@ -84,6 +89,7 @@ Library
mtl >= 2, mtl >= 2,
pandoc >= 1.10, pandoc >= 1.10,
parsec >= 3.1.1, parsec >= 3.1.1,
pretty,
shakespeare, shakespeare,
text, text,
template-haskell, template-haskell,
@ -95,14 +101,16 @@ Executable elm
Main-is: Compiler.hs Main-is: Compiler.hs
Hs-Source-Dirs: compiler Hs-Source-Dirs: compiler
other-modules: Unique, other-modules: Unique,
SourceSyntax.Helpers,
SourceSyntax.Location,
SourceSyntax.Literal,
SourceSyntax.Pattern,
SourceSyntax.Expression,
SourceSyntax.Declaration, SourceSyntax.Declaration,
SourceSyntax.Expression,
SourceSyntax.Everything,
SourceSyntax.Helpers,
SourceSyntax.Literal,
SourceSyntax.Location,
SourceSyntax.Module, SourceSyntax.Module,
SourceSyntax.Rename SourceSyntax.Pattern,
SourceSyntax.Rename,
SourceSyntax.Type,
Generate.JavaScript, Generate.JavaScript,
Generate.Noscript, Generate.Noscript,
Generate.Html, Generate.Html,
@ -113,21 +121,24 @@ Executable elm
Metadata.LoadLibraries, Metadata.LoadLibraries,
Initialize, Initialize,
Parse.Binop, Parse.Binop,
Parse.Declaration,
Parse.Expression, Parse.Expression,
Parse.Foreign,
Parse.Helpers, Parse.Helpers,
Parse.Literal, Parse.Literal,
Parse.Module, Parse.Module,
Parse.Parser, Parse.Parser,
Parse.Pattern, Parse.Pattern,
Parse.Type, Parse.Type,
Types.Alias, Type.Constrain.Declaration,
Types.Types, Type.Constrain.Expression,
Types.Constrain, Type.Constrain.Literal,
Types.Hints, Type.Constrain.Pattern,
Types.Solver, Type.Environment,
Types.Substitutions, Type.Fragment,
Types.Unify, Type.Solve,
Type.State,
Type.Type,
Type.Unify,
Paths_Elm Paths_Elm
Build-depends: base >=4.2 && <5, Build-depends: base >=4.2 && <5,
@ -145,6 +156,7 @@ Executable elm
mtl >= 2, mtl >= 2,
pandoc >= 1.10, pandoc >= 1.10,
parsec >= 3.1.1, parsec >= 3.1.1,
pretty,
transformers >= 0.2, transformers >= 0.2,
union-find, union-find,
uniplate uniplate
@ -169,6 +181,7 @@ Executable elm-doc
mtl >= 2, mtl >= 2,
parsec >= 3.1.1, parsec >= 3.1.1,
pandoc >= 1.10, pandoc >= 1.10,
pretty,
cmdargs, cmdargs,
filepath, filepath,
indents indents

View file

@ -4,16 +4,13 @@ module Main where
import SourceSyntax.Declaration (Declaration(Datatype)) import SourceSyntax.Declaration (Declaration(Datatype))
import Control.Applicative ((<$>), (<*>)) import Control.Applicative ((<$>), (<*>))
import Data.List (intercalate) import Data.List (intercalate)
import Data.Maybe (catMaybes) import Parse.Type
import Types.Types ((==>), Type ( ADT, VarT ) )
import Parse.Type (datatype)
import Parse.Helpers import Parse.Helpers
import Parse.Module (moduleDef) import Parse.Module (moduleDef)
import Text.Parsec hiding (newline,spaces) import Text.Parsec hiding (newline,spaces)
import System.Environment import System.Environment
import System.Exit import System.Exit
main = do main = do
srcs <- mapM readFile =<< getArgs srcs <- mapM readFile =<< getArgs
case mapM docParse srcs of case mapM docParse srcs of
@ -64,11 +61,13 @@ annotation exports =
typeDef = lookAhead ((string "data" <|> string "type") >> whitespace >> capVar) typeDef = lookAhead ((string "data" <|> string "type") >> whitespace >> capVar)
adt = do adt = do undefined
{-- TODO: reimplement this
(Datatype name tvs constructors) <- datatype (Datatype name tvs constructors) <- datatype
let toType (cName, typeArgs) = let toType (cName, typeArgs) =
(cName, show $ foldr (==>) (ADT name $ map VarT tvs) typeArgs, "") (cName, show $ foldr (==>) (kADT name $ map kVarT tvs) typeArgs, "")
return $ map toType constructors return $ map toType constructors
--}
setupParser p source = setupParser p source =
case iParse p "" source of case iParse p "" source of

View file

@ -14,7 +14,6 @@ import Generate.Cases
import SourceSyntax.Everything hiding (parens) import SourceSyntax.Everything hiding (parens)
import SourceSyntax.Location as Loc import SourceSyntax.Location as Loc
import Transform.SortDefinitions import Transform.SortDefinitions
import Types.Types ( Type(RecordT) )
showErr :: String -> String showErr :: String -> String
showErr err = globalAssign "Elm.Main" (jsFunc "elm" body) showErr err = globalAssign "Elm.Main" (jsFunc "elm" body)

View file

@ -9,14 +9,21 @@ import SourceSyntax.Everything
import Data.List (intercalate,partition) import Data.List (intercalate,partition)
import Parse.Parser (parseProgram, parseDependencies) import Parse.Parser (parseProgram, parseDependencies)
import qualified Metadata.Libraries as Libs import qualified Metadata.Libraries as Libs
import Types.Types ((-:))
import Types.Hints (hints)
import Types.Unify (unify)
import Types.Alias (dealias, mistakes)
import Transform.Optimize import Transform.Optimize
import System.Exit import System.Exit
import System.FilePath import System.FilePath
{-- TODO: replace with new stuff
import Types.Hints (hints)
import Types.Unify (unify)
import Types.Alias (dealias, mistakes)
--}
mistakes = undefined
unify = undefined
hints = undefined
checkMistakes :: (Data t, Data v) => Module t v -> Either String (Module t v) checkMistakes :: (Data t, Data v) => Module t v -> Either String (Module t v)
checkMistakes modul@(Module name ex im stmts) = checkMistakes modul@(Module name ex im stmts) =
case mistakes stmts of case mistakes stmts of

View file

@ -165,10 +165,10 @@ restore alreadyCopied variable = do
debug $ putStr "Restoring: " debug $ putStr "Restoring: "
desc <- liftIO $ UF.descriptor variable desc <- liftIO $ UF.descriptor variable
if mark desc /= alreadyCopied if mark desc /= alreadyCopied
then do then do
debug $ putStrLn "not copied, no need to do anything" debug $ putStrLn "not copied, no need to do anything"
return variable return variable
else do else do
debug $ putStrLn "restoring" debug $ putStrLn "restoring"
restoredStructure <- restoredStructure <-
case structure desc of case structure desc of