git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix for #171
29baa97Gary Burgess
src/Language/PureScript/TypeChecker/Monad.hs+14−4
@@ -115,10 +115,20 @@ data Environment = Environment {
115 } deriving (Show)
115 } deriving (Show)
116
116
117-- |
117-- |
118−-- An empty environment with no values and no types defined
118+-- The basic types existing in the external javascript environment
119--
119--
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+--
120−emptyEnvironment :: Environment
130+initEnvironment :: Environment
121−emptyEnvironment = Environment M.empty M.empty M.empty M.empty []
131+initEnvironment = Environment M.empty jsTypes M.empty M.empty []
122
132
123-- |
133-- |
124-- Temporarily bind a collection of names to values
134-- Temporarily bind a collection of names to values
@@ -271,7 +281,7 @@ modifyEnv f = modify (\s -> s { checkEnv = f (checkEnv s) })
271--
281--
272runCheck :: Check a -> Either String (a, Environment)
282runCheck :: Check a -> Either String (a, Environment)
273runCheck c = do
283runCheck 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
275 return (a, checkEnv s)
285 return (a, checkEnv s)
276
286
277-- |
287-- |
src/Language/PureScript/Types.hs+5−5
@@ -90,31 +90,31 @@ data Type
90-- Type constructor for functions
90-- Type constructor for functions
91--
91--
92tyFunction :: Type
92tyFunction :: Type
93−tyFunction = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelude") (ProperName "Function")
93+tyFunction = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prim") (ProperName "Function")
94
94
95-- |
95-- |
96-- Type constructor for strings
96-- Type constructor for strings
97--
97--
98tyString :: Type
98tyString :: Type
99−tyString = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelude") (ProperName "String")
99+tyString = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prim") (ProperName "String")
100
100
101-- |
101-- |
102-- Type constructor for numbers
102-- Type constructor for numbers
103--
103--
104tyNumber :: Type
104tyNumber :: Type
105−tyNumber = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelude") (ProperName "Number")
105+tyNumber = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prim") (ProperName "Number")
106
106
107-- |
107-- |
108-- Type constructor for booleans
108-- Type constructor for booleans
109--
109--
110tyBoolean :: Type
110tyBoolean :: Type
111−tyBoolean = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelude") (ProperName "Boolean")
111+tyBoolean = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prim") (ProperName "Boolean")
112
112
113-- |
113-- |
114-- Type constructor for arrays
114-- Type constructor for arrays
115--
115--
116tyArray :: Type
116tyArray :: Type
117−tyArray = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelude") (ProperName "Array")
117+tyArray = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prim") (ProperName "Array")
118
118
119-- |
119-- |
120-- Smart constructor for function types
120-- Smart constructor for function types