summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilFreeman <>2014-01-10 19:59:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2014-01-10 19:59:00 (GMT)
commitf14e0a7e3a2b5efc455480c1d110fddc648214a5 (patch)
treeb6ac904f83d4c677674dd4dbec08134a1acda92d
parent8c76ca27dc08843206b3b8eedbc3a3962e88115f (diff)
version 0.2.9.20.2.9.2
-rw-r--r--purescript.cabal50
-rw-r--r--src/Language/PureScript.hs1
-rw-r--r--src/Language/PureScript/CodeGen.hs1
-rw-r--r--src/Language/PureScript/CodeGen/JS.hs21
-rw-r--r--src/Language/PureScript/CodeGen/Optimize.hs (renamed from src/Language/PureScript/Optimize.hs)2
5 files changed, 53 insertions, 22 deletions
diff --git a/purescript.cabal b/purescript.cabal
index 2b90b20..4769c67 100644
--- a/purescript.cabal
+++ b/purescript.cabal
@@ -1,5 +1,5 @@
name: purescript
-version: 0.2.9.1
+version: 0.2.9.2
cabal-version: >=1.8
build-type: Simple
license: MIT
@@ -17,29 +17,45 @@ library
build-depends: base >=4 && <5, cmdtheline -any, containers -any,
directory -any, filepath -any, mtl -any, parsec -any, syb -any,
transformers -any, utf8-string -any
- exposed-modules: Language.PureScript.Options Data.Generics.Extras
- Language.PureScript Language.PureScript.CodeGen
- Language.PureScript.CodeGen.Externs Language.PureScript.CodeGen.JS
+ exposed-modules: Data.Generics.Extras
+ Language.PureScript.Options
+ Language.PureScript
+ Language.PureScript.CodeGen
+ Language.PureScript.CodeGen.Externs
+ Language.PureScript.CodeGen.JS
Language.PureScript.CodeGen.JS.AST
- Language.PureScript.CodeGen.Monad Language.PureScript.Declarations
- Language.PureScript.Kinds Language.PureScript.Names
- Language.PureScript.Operators Language.PureScript.Optimize
- Language.PureScript.Parser Language.PureScript.Parser.Common
+ Language.PureScript.CodeGen.Monad
+ Language.PureScript.CodeGen.Optimize
+ Language.PureScript.Declarations
+ Language.PureScript.Kinds
+ Language.PureScript.Names
+ Language.PureScript.Operators
+ Language.PureScript.Parser
+ Language.PureScript.Parser.Common
Language.PureScript.Parser.Declarations
- Language.PureScript.Parser.Kinds Language.PureScript.Parser.State
- Language.PureScript.Parser.Types Language.PureScript.Parser.Values
- Language.PureScript.Pretty Language.PureScript.Pretty.Common
- Language.PureScript.Pretty.JS Language.PureScript.Pretty.Kinds
- Language.PureScript.Pretty.Types Language.PureScript.Pretty.Values
+ Language.PureScript.Parser.Kinds
+ Language.PureScript.Parser.State
+ Language.PureScript.Parser.Types
+ Language.PureScript.Parser.Values
+ Language.PureScript.Pretty
+ Language.PureScript.Pretty.Common
+ Language.PureScript.Pretty.JS
+ Language.PureScript.Pretty.Kinds
+ Language.PureScript.Pretty.Types
+ Language.PureScript.Pretty.Values
Language.PureScript.TypeChecker
Language.PureScript.TypeChecker.Kinds
Language.PureScript.TypeChecker.Monad
Language.PureScript.TypeChecker.Synonyms
- Language.PureScript.TypeChecker.Types Language.PureScript.Types
- Language.PureScript.Unknown Language.PureScript.Values Main
- Language.PureScript.CaseDeclarations Language.PureScript.DoNotation
+ Language.PureScript.TypeChecker.Types
+ Language.PureScript.Types
+ Language.PureScript.Unknown
+ Language.PureScript.Values
+ Language.PureScript.CaseDeclarations
+ Language.PureScript.DoNotation
Language.PureScript.TypeDeclarations
- Language.PureScript.BindingGroups Language.PureScript.Scope
+ Language.PureScript.BindingGroups
+ Language.PureScript.Scope
exposed: True
buildable: True
hs-source-dirs: src
diff --git a/src/Language/PureScript.hs b/src/Language/PureScript.hs
index bea407a..0c64fbb 100644
--- a/src/Language/PureScript.hs
+++ b/src/Language/PureScript.hs
@@ -23,7 +23,6 @@ import Language.PureScript.Parser as P
import Language.PureScript.CodeGen as P
import Language.PureScript.TypeChecker as P
import Language.PureScript.Pretty as P
-import Language.PureScript.Optimize as P
import Language.PureScript.Operators as P
import Language.PureScript.CaseDeclarations as P
import Language.PureScript.TypeDeclarations as P
diff --git a/src/Language/PureScript/CodeGen.hs b/src/Language/PureScript/CodeGen.hs
index 7cb111d..a5bee01 100644
--- a/src/Language/PureScript/CodeGen.hs
+++ b/src/Language/PureScript/CodeGen.hs
@@ -16,3 +16,4 @@ module Language.PureScript.CodeGen (module C) where
import Language.PureScript.CodeGen.JS as C
import Language.PureScript.CodeGen.Externs as C
+import Language.PureScript.CodeGen.Optimize as C
diff --git a/src/Language/PureScript/CodeGen/JS.hs b/src/Language/PureScript/CodeGen/JS.hs
index d9426b0..af95cc1 100644
--- a/src/Language/PureScript/CodeGen/JS.hs
+++ b/src/Language/PureScript/CodeGen/JS.hs
@@ -53,9 +53,24 @@ declToJs opts mp (BindingGroupDeclaration vals) e =
[ JSVariableIntroduction ident (Just (valueToJs opts mp e val)),
setProperty (identToJs ident) (JSVar ident) mp ]
) vals
-declToJs _ mp (ExternMemberDeclaration member ident _) _ =
- Just [ JSFunction (Just ident) [Ident "value"] (JSBlock [JSReturn (JSAccessor member (JSVar (Ident "value")))]),
- setProperty (show ident) (JSVar ident) mp ]
+declToJs _ mp (ExternMemberDeclaration member ident ty) _
+ | returnsFunction ty =
+ Just [ JSFunction (Just ident) [Ident "value"] (JSBlock
+ [ JSReturn $ JSApp (JSAccessor "bind" (JSAccessor member (JSVar (Ident "value")))) [JSVar (Ident "value")]
+ ]),
+ setProperty (show ident) (JSVar ident) mp ]
+ | otherwise =
+ Just [ JSFunction (Just ident) [Ident "value"] (JSBlock
+ [ JSReturn $ JSAccessor member (JSVar (Ident "value"))
+ ]),
+ setProperty (show ident) (JSVar ident) mp ]
+ where
+ returnsFunction (Function _ ret) = isFunction ret
+ returnsFunction (ForAll _ ty') = returnsFunction ty'
+ returnsFunction _ = error "Expected function type in declToJs"
+ isFunction (Function _ _) = True
+ isFunction (ForAll _ ty') = isFunction ty'
+ isFunction _ = False
declToJs _ mp (DataDeclaration _ _ ctors) _ =
Just $ flip concatMap ctors $ \(pn@(ProperName ctor), maybeTy) ->
let
diff --git a/src/Language/PureScript/Optimize.hs b/src/Language/PureScript/CodeGen/Optimize.hs
index 63c1470..4c5ca78 100644
--- a/src/Language/PureScript/Optimize.hs
+++ b/src/Language/PureScript/CodeGen/Optimize.hs
@@ -12,7 +12,7 @@
--
-----------------------------------------------------------------------------
-module Language.PureScript.Optimize (
+module Language.PureScript.CodeGen.Optimize (
optimize
) where