summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilFreeman <>2014-04-27 19:49:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2014-04-27 19:49:00 (GMT)
commit73e8826ca8c27be924b76331963fee3ab3d1464a (patch)
treeaa38893c987f3a31bd09f53a133e17e38fe7c9a6
parent4f5c6e6810eca03d0caf685b6f932cac676936be (diff)
version 0.5.00.5.0
-rw-r--r--purescript.cabal2
-rw-r--r--src/Language/PureScript/CodeGen/JS.hs4
-rw-r--r--src/Language/PureScript/TypeChecker/Types.hs1
3 files changed, 5 insertions, 2 deletions
diff --git a/purescript.cabal b/purescript.cabal
index 79ba8e4..316193c 100644
--- a/purescript.cabal
+++ b/purescript.cabal
@@ -1,5 +1,5 @@
name: purescript
-version: 0.4.20
+version: 0.5.0
cabal-version: >=1.8
build-type: Custom
license: MIT
diff --git a/src/Language/PureScript/CodeGen/JS.hs b/src/Language/PureScript/CodeGen/JS.hs
index fa1f404..790ff61 100644
--- a/src/Language/PureScript/CodeGen/JS.hs
+++ b/src/Language/PureScript/CodeGen/JS.hs
@@ -56,13 +56,15 @@ data ModuleType = CommonJS | Globals
moduleToJs :: ModuleType -> Options -> Module -> Environment -> [JS]
moduleToJs mt opts (Module name decls (Just exps)) env = case mt of
CommonJS -> moduleBody ++ [JSAssignment (JSAccessor "exports" (JSVar "module")) moduleExports]
- Globals ->
+ Globals | not isModuleEmpty ->
[ JSVariableIntroduction (fromJust (optionsBrowserNamespace opts))
(Just (JSBinary Or (JSVar (fromJust (optionsBrowserNamespace opts))) (JSObjectLiteral [])) )
, JSAssignment (JSAccessor (moduleNameToJs name) (JSVar (fromJust (optionsBrowserNamespace opts))))
(JSApp (JSFunction Nothing [] (JSBlock (moduleBody ++ [JSReturn moduleExports]))) [])
]
+ _ -> []
where
+ isModuleEmpty = null jsDecls
moduleBody = JSStringLiteral "use strict" : jsImports ++ jsDecls
moduleExports = JSObjectLiteral $ concatMap exportToJs exps
jsDecls = (concat $ mapMaybe (\decl -> fmap (map $ optimize opts) $ declToJs opts name decl env) decls)
diff --git a/src/Language/PureScript/TypeChecker/Types.hs b/src/Language/PureScript/TypeChecker/Types.hs
index d2003df..04e4f1b 100644
--- a/src/Language/PureScript/TypeChecker/Types.hs
+++ b/src/Language/PureScript/TypeChecker/Types.hs
@@ -421,6 +421,7 @@ pairwise p (x : xs) = all (p x) xs && pairwise p xs
-- Check that two types unify
--
unifiesWith :: Environment -> Type -> Type -> Bool
+unifiesWith _ (TUnknown u1) (TUnknown u2) | u1 == u2 = True
unifiesWith _ (Skolem _ s1 _) (Skolem _ s2 _) | s1 == s2 = True
unifiesWith _ (TypeVar v1) (TypeVar v2) | v1 == v2 = True
unifiesWith _ (TypeConstructor c1) (TypeConstructor c2) | c1 == c2 = True