git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix for #171
commit29baa9716506106c065ea81c3743a50fe721adc8 authorGary Burgess <garyb@users.noreply.github.com> dateThu 6 Feb 2014, 23:58 (13 years ago) parent67fb0b2
2 files changed+19−9
src/Language/PureScript/TypeChecker/Monad.hs+14−4 src/Language/PureScript/Types.hs+5−5
src/Language/PureScript/TypeChecker/Monad.hs+14−4
@@ -115,10 +115,20 @@ data Environment = Environment {
115115 } deriving (Show)
116116
117117-- |
118−-- An empty environment with no values and no types defined
118+-- The basic types existing in the external javascript environment
119119--
120−emptyEnvironment :: Environment
121−emptyEnvironment = Environment M.empty M.empty M.empty M.empty []
120+jsTypes ::M.Map (ModuleName, ProperName) (Kind, TypeDeclarationKind)
121+jsTypes = M.fromList [ ((ModuleName $ ProperName "Prim", ProperName "Function"), (FunKind Star $ FunKind Star Star, ExternData))
122+ , ((ModuleName $ ProperName "Prim", ProperName "Array"), (FunKind Star Star, ExternData))
123+ , ((ModuleName $ ProperName "Prim", ProperName "String"), (Star, ExternData))
124+ , ((ModuleName $ ProperName "Prim", ProperName "Number"), (Star, ExternData))
125+ , ((ModuleName $ ProperName "Prim", ProperName "Boolean"), (Star, ExternData)) ]
126+
127+-- |
128+-- The initial environment with no values and only the default javascript types defined
129+--
130+initEnvironment :: Environment
131+initEnvironment = Environment M.empty jsTypes M.empty M.empty []
122132
123133-- |
124134-- Temporarily bind a collection of names to values
@@ -271,7 +281,7 @@ modifyEnv f = modify (\s -> s { checkEnv = f (checkEnv s) })
271281--
272282runCheck :: Check a -> Either String (a, Environment)
273283runCheck c = do
274− (a, s) <- flip runStateT (CheckState emptyEnvironment 0 0 Nothing) $ unCheck c
284+ (a, s) <- flip runStateT (CheckState initEnvironment 0 0 Nothing) $ unCheck c
275285 return (a, checkEnv s)
276286
277287-- |
src/Language/PureScript/Types.hs+5−5
@@ -90,31 +90,31 @@ data Type
9090-- Type constructor for functions
9191--
9292tyFunction :: Type
93−tyFunction = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelude") (ProperName "Function")
93+tyFunction = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prim") (ProperName "Function")
9494
9595-- |
9696-- Type constructor for strings
9797--
9898tyString :: Type
99−tyString = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelude") (ProperName "String")
99+tyString = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prim") (ProperName "String")
100100
101101-- |
102102-- Type constructor for numbers
103103--
104104tyNumber :: Type
105−tyNumber = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelude") (ProperName "Number")
105+tyNumber = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prim") (ProperName "Number")
106106
107107-- |
108108-- Type constructor for booleans
109109--
110110tyBoolean :: Type
111−tyBoolean = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelude") (ProperName "Boolean")
111+tyBoolean = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prim") (ProperName "Boolean")
112112
113113-- |
114114-- Type constructor for arrays
115115--
116116tyArray :: Type
117−tyArray = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelude") (ProperName "Array")
117+tyArray = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prim") (ProperName "Array")
118118
119119-- |
120120-- Smart constructor for function types