diff --git a/flake.lock b/flake.lock index 30d0f27..4d98b8b 100644 --- a/flake.lock +++ b/flake.lock @@ -174,11 +174,11 @@ "ghc910X": { "flake": false, "locked": { - "lastModified": 1709693152, - "narHash": "sha256-j7K/oZLy1ZZIpOsjq101IF7cz/i/UxY1ofIeNUfuuXc=", + "lastModified": 1711543129, + "narHash": "sha256-MUI07CxYOng7ZwHnMCw0ugY3HmWo2p/f4r07CGV7OAM=", "ref": "ghc-9.10", - "rev": "21e3f3250e88640087a1a60bee2cc113bf04509f", - "revCount": 62524, + "rev": "6ecd5f2ff97af53c7334f2d8581651203a2c6b7d", + "revCount": 62607, "submodules": true, "type": "git", "url": "https://gitlab.haskell.org/ghc/ghc" @@ -193,11 +193,11 @@ "ghc911": { "flake": false, "locked": { - "lastModified": 1710286031, - "narHash": "sha256-fz71zsU/ZukFMUsRNk2Ro3xTNMKsNrpvQtRtPqRI60c=", + "lastModified": 1711538967, + "narHash": "sha256-KSdOJ8seP3g30FaC2du8QjU9vumMnmzPR5wfkVRXQMk=", "ref": "refs/heads/master", - "rev": "e6bfb85c842edca36754bb8914e725fbaa1a83a6", - "revCount": 62586, + "rev": "0acfe391583d77a72051d505f05fab0ada056c49", + "revCount": 62632, "submodules": true, "type": "git", "url": "https://gitlab.haskell.org/ghc/ghc" @@ -211,11 +211,11 @@ "hackage": { "flake": false, "locked": { - "lastModified": 1710807758, - "narHash": "sha256-lQY4KSZQlMyKizC+Xbsl29hxNPHV52pRTDZac+vPaeU=", + "lastModified": 1713572844, + "narHash": "sha256-/XWI1qyfIaR2+Zfp9sFSkCS0tSLQ2kT8rZ8YO6TEC+w=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "dc3cafd9dbaeebe37c96613a9d145e162cadcf79", + "rev": "5fbda11a1e6c32f1deee000160bb67dfa9e06855", "type": "github" }, "original": { @@ -243,10 +243,10 @@ "hls-2.4": "hls-2.4", "hls-2.5": "hls-2.5", "hls-2.6": "hls-2.6", + "hls-2.7": "hls-2.7", "hpc-coveralls": "hpc-coveralls", "hydra": "hydra", "iserv-proxy": "iserv-proxy", - "nix-tools-static": "nix-tools-static", "nixpkgs": [ "haskellNix", "nixpkgs-unstable" @@ -263,11 +263,11 @@ "stackage": "stackage" }, "locked": { - "lastModified": 1710809412, - "narHash": "sha256-uLn/+4rBqk/+y5OPqe0LqUZHW7uEnWiljO/oGEx3L7c=", + "lastModified": 1713574219, + "narHash": "sha256-QLCxxfmht4POO73ld1EH0w/GTb3XLgKLXcCitkMkLrs=", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "bc43eea89699683d1659eed3c3cc787e432ebfe7", + "rev": "e43654102de69c2a4ddfdcb067d42f203f0ecf51", "type": "github" }, "original": { @@ -395,6 +395,23 @@ "type": "github" } }, + "hls-2.7": { + "flake": false, + "locked": { + "lastModified": 1708965829, + "narHash": "sha256-LfJ+TBcBFq/XKoiNI7pc4VoHg4WmuzsFxYJ3Fu+Jf+M=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "50322b0a4aefb27adc5ec42f5055aaa8f8e38001", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.7.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, "hpc-coveralls": { "flake": false, "locked": { @@ -488,23 +505,6 @@ "type": "github" } }, - "nix-tools-static": { - "flake": false, - "locked": { - "lastModified": 1706266250, - "narHash": "sha256-9t+GRk3eO9muCtKdNAwBtNBZ5dH1xHcnS17WaQyftwA=", - "owner": "input-output-hk", - "repo": "haskell-nix-example", - "rev": "580cb6db546a7777dad3b9c0fa487a366c045c4e", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "ref": "nix", - "repo": "haskell-nix-example", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1657693803, @@ -696,11 +696,11 @@ "stackage": { "flake": false, "locked": { - "lastModified": 1710461339, - "narHash": "sha256-l2/ekwA4Z4NjiaCZytZrBTag2VaAOBUvsNttsH6kH4E=", + "lastModified": 1713572055, + "narHash": "sha256-gyxWqQhTvI7MvSWj9tNBWvUIUw9I1RkoCkKYmT6nMQ8=", "owner": "input-output-hk", "repo": "stackage.nix", - "rev": "724970b7dc837bf0d813b91f821948c3c5cc719f", + "rev": "0b92a647a8e834c8c13c346149501d50e85d7380", "type": "github" }, "original": { diff --git a/lib/Language/PureScript/Backend.hs b/lib/Language/PureScript/Backend.hs index 64f6a8f..bd020d5 100644 --- a/lib/Language/PureScript/Backend.hs +++ b/lib/Language/PureScript/Backend.hs @@ -44,6 +44,7 @@ compileModules outputDir foreignDir appOrModule = do let needsRuntimeLazy = Tagged (any untag needsRuntimeLazys) chunk ← Lua.fromUberModule foreignDir needsRuntimeLazy appOrModule uberModule pure CompilationResult {lua = optimizeChunk chunk, ir = uberModule} + linkerMode ∷ AppOrModule → Linker.LinkMode linkerMode = \case AsModule psModuleName → Linker.LinkAsModule psModuleName diff --git a/lib/Language/PureScript/Backend/Lua.hs b/lib/Language/PureScript/Backend/Lua.hs index 51dbf40..f1b9dd1 100644 --- a/lib/Language/PureScript/Backend/Lua.hs +++ b/lib/Language/PureScript/Backend/Lua.hs @@ -4,7 +4,7 @@ module Language.PureScript.Backend.Lua ( fromUberModule , fromIR , fromName - , fromQName + -- , qualifyName , qualifyName , Error (..) ) where @@ -66,23 +66,28 @@ fromUberModule → Linker.UberModule → ExceptT (Variant e) IO Lua.Chunk fromUberModule foreigns needsRuntimeLazy appOrModule uber = (`evalStateT` 0) do - (chunk, usesObjectUpdate) ← (`runAccumT` NoObjectUpdate) do + ((bindings, returnStat), usesObjectUpdate) ← (`runAccumT` NoObjectUpdate) do foreignBindings ← forM (Linker.uberModuleForeigns uber) \(IR.QName modname name, irExp) → do exp ← asExpression <$> fromIR foreigns Set.empty modname irExp - pure $ Lua.assign (Lua.VarName (fromQName modname name)) exp + pure $ mkBinding modname (fromName name) exp + bindings ← Linker.uberModuleBindings uber & foldMapM \case IR.Standalone (IR.QName modname name, irExp) → do exp ← fromIR foreigns Set.empty modname irExp pure . DList.singleton $ - Lua.assignVar (fromQName modname name) (asExpression exp) + mkBinding modname (fromName name) (asExpression exp) IR.RecursiveGroup recGroup → do recBinds ← forM (toList recGroup) \(IR.QName modname name, irExp) → - (fromQName modname name,) . asExpression + (modname,name,) . asExpression <$> fromIR foreigns Set.empty modname irExp - let declarations = Lua.local0 . fst <$> DList.fromList recBinds - assignments = DList.fromList (uncurry Lua.assignVar <$> recBinds) + let declarations = DList.fromList do + (modname, name, _exp) ← recBinds + pure $ mkBinding modname (fromName name) Lua.Nil + assignments = DList.fromList do + (modname, name, exp) ← recBinds + pure $ mkBinding modname (fromName name) exp pure $ declarations <> assignments returnExp ← @@ -100,25 +105,36 @@ fromUberModule foreigns needsRuntimeLazy appOrModule uber = (`evalStateT` 0) do where name = IR.identToName ident - pure $ - DList.fromList foreignBindings - <> DList.snoc bindings (Lua.Return (Lua.ann returnExp)) + pure + ( DList.fromList foreignBindings <> bindings + , Lua.Return (Lua.ann returnExp) + ) pure . mconcat $ - [ [Fixture.prim | usesPrimModule uber] + [ [Lua.assign moduleVar (Lua.table []) | not (null bindings)] + , [ mkBinding Fixture.primModule Fixture.undefined Lua.Nil + | usesPrimModule uber + ] , [Fixture.runtimeLazy | untag needsRuntimeLazy && usesRuntimeLazy uber] , [Fixture.objectUpdate | UsesObjectUpdate ← [usesObjectUpdate]] - , DList.toList chunk + , toList (DList.snoc bindings returnStat) ] +mkBinding ∷ ModuleName → Lua.Name → Lua.Exp → Lua.Statement +mkBinding modname name = + Lua.assign $ + Lua.VarField + (Lua.ann (Lua.var moduleVar)) + (qualifyName modname name) + +moduleVar ∷ Lua.Var +moduleVar = Lua.VarName [Lua.name|M|] + asExpression ∷ Either Lua.Chunk Lua.Exp → Lua.Exp asExpression = \case Left chunk → Lua.chunkToExpression chunk Right expr → expr -fromQName ∷ ModuleName → IR.Name → Lua.Name -fromQName modname name = qualifyName modname (fromName name) - fromName ∷ HasCallStack ⇒ IR.Name → Lua.Name fromName = Name.makeSafe . IR.nameToText @@ -203,13 +219,13 @@ fromIR foreigns topLevelNames modname ir = case ir of IR.Ref _ann qualifiedName index → pure . Right $ case qualifiedName of IR.Local name - | topLevelName ← fromQName modname name + | topLevelName ← qualifyName modname (fromName name) , Set.member topLevelName topLevelNames → - Lua.varName topLevelName + Lua.varField (Lua.var moduleVar) topLevelName IR.Local name → Lua.varName (fromNameWithIndex name index) IR.Imported modname' name → - Lua.varName (fromQName modname' name) + Lua.varField (Lua.var moduleVar) (qualifyName modname' (fromName name)) IR.Let _ann bindings bodyExp → do body ← go bodyExp recs ← @@ -218,18 +234,22 @@ fromIR foreigns topLevelNames modname ir = case ir of DList.singleton . Lua.local1 (fromName name) <$> goExp expr IR.RecursiveGroup grp → do let binds = - toList grp <&> \(_ann, irName, _) → do - let name = - if Set.member (fromQName modname irName) topLevelNames - then fromQName modname irName - else fromName irName - Lua.Local name Nothing - assignments ← forM (toList grp) \(_ann, irName, expr) → do - let name = - if Set.member (fromQName modname irName) topLevelNames - then fromQName modname irName - else fromName irName - Lua.assign (Lua.VarName name) <$> goExp expr + toList grp <&> \(_ann, fromName → name, _) → + Lua.Local + ( if Set.member (qualifyName modname name) topLevelNames + then qualifyName modname name + else name + ) + Nothing + assignments ← forM (toList grp) \(_ann, fromName → name, expr) → + goExp expr + <&> Lua.assign + ( Lua.VarName + ( if Set.member (qualifyName modname name) topLevelNames + then qualifyName modname name + else name + ) + ) pure $ DList.fromList binds <> DList.fromList assignments pure . Left . DList.toList $ recs <> either DList.fromList (DList.singleton . Lua.return) body diff --git a/lib/Language/PureScript/Backend/Lua/Fixture.hs b/lib/Language/PureScript/Backend/Lua/Fixture.hs index fb23f77..dc02760 100644 --- a/lib/Language/PureScript/Backend/Lua/Fixture.hs +++ b/lib/Language/PureScript/Backend/Lua/Fixture.hs @@ -6,15 +6,22 @@ import Data.String.Interpolate (__i) import Language.PureScript.Backend.Lua.Name (Name, name, unsafeName) import Language.PureScript.Backend.Lua.Name qualified as Name import Language.PureScript.Backend.Lua.Types hiding (var) +import Language.PureScript.Backend.IR.Names (ModuleName(..)) -------------------------------------------------------------------------------- -- Hard-coded Lua pieces ------------------------------------------------------- -prim ∷ Statement -prim = assignVar (primName [name|undefined|]) Nil +prim ∷ Name +prim = [name|Prim|] + +primModule :: ModuleName +primModule = ModuleName "Prim" + +undefined ∷ Name +undefined = primName [name|undefined|] primName ∷ Name → Name -primName = psluaName . Name.join2 [name|Prim|] +primName = psluaName . Name.join2 prim uniqueName ∷ MonadState Natural m ⇒ Text → m Name uniqueName prefix = do diff --git a/lib/Language/PureScript/Backend/Types.hs b/lib/Language/PureScript/Backend/Types.hs index b8d6679..470896a 100644 --- a/lib/Language/PureScript/Backend/Types.hs +++ b/lib/Language/PureScript/Backend/Types.hs @@ -9,5 +9,5 @@ data AppOrModule entryPointModule ∷ AppOrModule → PS.ModuleName entryPointModule = \case - AsApplication modul _ident → modul - AsModule modul → modul + AsApplication modname _ident → modname + AsModule modname → modname diff --git a/test/ps/output/Golden.Annotations.M1/golden.lua b/test/ps/output/Golden.Annotations.M1/golden.lua index 32f5694..34d7993 100644 --- a/test/ps/output/Golden.Annotations.M1/golden.lua +++ b/test/ps/output/Golden.Annotations.M1/golden.lua @@ -1,4 +1,5 @@ -PSLUA_Golden_Annotations_M1_foreign = (function() +M = {} +M.PSLUA_Golden_Annotations_M1_foreign = (function() local step = 2 return { dontInlineClosure = function(i) @@ -11,6 +12,6 @@ PSLUA_Golden_Annotations_M1_foreign = (function() end)() return { inlineMe = function(v) if 1 == v then return 2 else return v end end, - dontInlineClosure = PSLUA_Golden_Annotations_M1_foreign.dontInlineClosure, - inlineMeLambda = PSLUA_Golden_Annotations_M1_foreign.inlineMeLambda + dontInlineClosure = M.PSLUA_Golden_Annotations_M1_foreign.dontInlineClosure, + inlineMeLambda = M.PSLUA_Golden_Annotations_M1_foreign.inlineMeLambda } diff --git a/test/ps/output/Golden.Annotations.M2/golden.lua b/test/ps/output/Golden.Annotations.M2/golden.lua index cdece4b..f5eec6b 100644 --- a/test/ps/output/Golden.Annotations.M2/golden.lua +++ b/test/ps/output/Golden.Annotations.M2/golden.lua @@ -1,4 +1,5 @@ -PSLUA_Golden_Annotations_M1_foreign = (function() +M = {} +M.PSLUA_Golden_Annotations_M1_foreign = (function() local step = 2 return { dontInlineClosure = function(i) @@ -27,5 +28,5 @@ return { end end end, - inlineIntoMe2 = PSLUA_Golden_Annotations_M1_foreign.dontInlineClosure(PSLUA_Golden_Annotations_M1_foreign.inlineMeLambda(PSLUA_Golden_Annotations_M1_foreign.inlineMeLambda(17))) + inlineIntoMe2 = M.PSLUA_Golden_Annotations_M1_foreign.dontInlineClosure(M.PSLUA_Golden_Annotations_M1_foreign.inlineMeLambda(M.PSLUA_Golden_Annotations_M1_foreign.inlineMeLambda(17))) } diff --git a/test/ps/output/Golden.CaseStatements.Test/golden.lua b/test/ps/output/Golden.CaseStatements.Test/golden.lua index f426def..bd758bc 100644 --- a/test/ps/output/Golden.CaseStatements.Test/golden.lua +++ b/test/ps/output/Golden.CaseStatements.Test/golden.lua @@ -1,11 +1,12 @@ -PSLUA_Golden_Values_Test_f = function(unused0) return true end +M = {} +M.PSLUA_Golden_Values_Test_f = function(unused0) return true end return { a = 1, b = "b", c = (function() local v = function(unused1) return 0 end - if PSLUA_Golden_Values_Test_f(2) then - if PSLUA_Golden_Values_Test_f(1) then return 42 else return v(true) end + if M.PSLUA_Golden_Values_Test_f(2) then + if M.PSLUA_Golden_Values_Test_f(1) then return 42 else return v(true) end else return v(true) end diff --git a/test/ps/output/Golden.Foreign.Lib/golden.lua b/test/ps/output/Golden.Foreign.Lib/golden.lua index 9c0fc0b..519decf 100644 --- a/test/ps/output/Golden.Foreign.Lib/golden.lua +++ b/test/ps/output/Golden.Foreign.Lib/golden.lua @@ -1,5 +1,6 @@ -PSLUA_Golden_Foreign_Lib_foreign = { dead = -100, alive = 100 } +M = {} +M.PSLUA_Golden_Foreign_Lib_foreign = { dead = -100, alive = 100 } return { - dead = PSLUA_Golden_Foreign_Lib_foreign.dead, - alive = PSLUA_Golden_Foreign_Lib_foreign.alive + dead = M.PSLUA_Golden_Foreign_Lib_foreign.dead, + alive = M.PSLUA_Golden_Foreign_Lib_foreign.alive } diff --git a/test/ps/output/Golden.Foreign.Test/golden.lua b/test/ps/output/Golden.Foreign.Test/golden.lua index d892663..0dc2e86 100644 --- a/test/ps/output/Golden.Foreign.Test/golden.lua +++ b/test/ps/output/Golden.Foreign.Test/golden.lua @@ -1,8 +1,9 @@ -PSLUA_Golden_Foreign_Test_foreign = (function() +M = {} +M.PSLUA_Golden_Foreign_Test_foreign = (function() local fooBar = 42 return { foo = fooBar + 1, boo = fooBar + 2 } end)() return { - foo = PSLUA_Golden_Foreign_Test_foreign.foo, - baz = { [1] = PSLUA_Golden_Foreign_Test_foreign.boo, [2] = 100 } + foo = M.PSLUA_Golden_Foreign_Test_foreign.foo, + baz = { [1] = M.PSLUA_Golden_Foreign_Test_foreign.boo, [2] = 100 } } diff --git a/test/ps/output/Golden.HelloPrelude.Test/golden.ir b/test/ps/output/Golden.HelloPrelude.Test/golden.ir index 34ebbf7..b012e48 100644 --- a/test/ps/output/Golden.HelloPrelude.Test/golden.ir +++ b/test/ps/output/Golden.HelloPrelude.Test/golden.ir @@ -206,7 +206,7 @@ UberModule ) ( ObjectProp ( Just Always ) ( ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/prelude/v7.1.0/src/Data/Unit.purs" + ( ModuleName "Data.Unit" ) ".spago/prelude/v7.1.1/src/Data/Unit.purs" [ ( Nothing, Name "unit" ) ] ) ( PropName "unit" ) diff --git a/test/ps/output/Golden.HelloPrelude.Test/golden.lua b/test/ps/output/Golden.HelloPrelude.Test/golden.lua index dc92fc7..293cdae 100644 --- a/test/ps/output/Golden.HelloPrelude.Test/golden.lua +++ b/test/ps/output/Golden.HelloPrelude.Test/golden.lua @@ -1,4 +1,5 @@ -PSLUA_Prim_undefined = nil +M = {} +M.PSLUA_Prim_PSLUA_Prim_undefined = nil function PSLUA_runtime_lazy(name) return function(init) return function() @@ -19,7 +20,7 @@ function PSLUA_runtime_lazy(name) end end end -PSLUA_Effect_foreign = { +M.PSLUA_Effect_foreign = { pureE = function(a) return function() return a @@ -33,50 +34,50 @@ PSLUA_Effect_foreign = { end end } -PSLUA_Control_Applicative_pure = function(dict) return dict.pure end -local PSLUA_Effect_monadEffect -local PSLUA_Effect_bindEffect -local PSLUA_Effect_applicativeEffect -local PSLUA_Effect_PSLUA_lazy_functorEffect -local PSLUA_Effect_PSLUA_lazy_applyEffect -PSLUA_Effect_monadEffect = { - Applicative0 = function(unused0) return PSLUA_Effect_applicativeEffect end, - Bind1 = function(unused1) return PSLUA_Effect_bindEffect end +M.PSLUA_Control_Applicative_pure = function(dict) return dict.pure end +M.PSLUA_Effect_monadEffect = nil +M.PSLUA_Effect_bindEffect = nil +M.PSLUA_Effect_applicativeEffect = nil +M.PSLUA_Effect_PSLUA_lazy_functorEffect = nil +M.PSLUA_Effect_PSLUA_lazy_applyEffect = nil +M.PSLUA_Effect_monadEffect = { + Applicative0 = function(unused0) return M.PSLUA_Effect_applicativeEffect end, + Bind1 = function(unused1) return M.PSLUA_Effect_bindEffect end } -PSLUA_Effect_bindEffect = { - bind = PSLUA_Effect_foreign.bindE, - Apply0 = function(unused2) return PSLUA_Effect_PSLUA_lazy_applyEffect(0) end +M.PSLUA_Effect_bindEffect = { + bind = M.PSLUA_Effect_foreign.bindE, + Apply0 = function(unused2) return M.PSLUA_Effect_PSLUA_lazy_applyEffect(0) end } -PSLUA_Effect_applicativeEffect = { - pure = PSLUA_Effect_foreign.pureE, - Apply0 = function(unused3) return PSLUA_Effect_PSLUA_lazy_applyEffect(0) end +M.PSLUA_Effect_applicativeEffect = { + pure = M.PSLUA_Effect_foreign.pureE, + Apply0 = function(unused3) return M.PSLUA_Effect_PSLUA_lazy_applyEffect(0) end } -PSLUA_Effect_PSLUA_lazy_functorEffect = PSLUA_runtime_lazy("functorEffect")(function( unused4 ) +M.PSLUA_Effect_PSLUA_lazy_functorEffect = PSLUA_runtime_lazy("functorEffect")(function( unused4 ) return { map = function(f) - return (PSLUA_Effect_applicativeEffect.Apply0(PSLUA_Prim_undefined)).apply(PSLUA_Control_Applicative_pure(PSLUA_Effect_applicativeEffect)(f)) + return (M.PSLUA_Effect_applicativeEffect.Apply0(M.PSLUA_Prim_undefined)).apply(M.PSLUA_Control_Applicative_pure(M.PSLUA_Effect_applicativeEffect)(f)) end } end) -PSLUA_Effect_PSLUA_lazy_applyEffect = PSLUA_runtime_lazy("applyEffect")(function( unused6 ) +M.PSLUA_Effect_PSLUA_lazy_applyEffect = PSLUA_runtime_lazy("applyEffect")(function( unused6 ) return { apply = (function() return function(f) - local bind = (PSLUA_Effect_monadEffect.Bind1(PSLUA_Prim_undefined)).bind + local bind = (M.PSLUA_Effect_monadEffect.Bind1(M.PSLUA_Prim_undefined)).bind return function(a) return bind(f)(function(fPrime) return bind(a)(function(aPrime) - return PSLUA_Control_Applicative_pure(PSLUA_Effect_monadEffect.Applicative0(PSLUA_Prim_undefined))(fPrime(aPrime)) + return M.PSLUA_Control_Applicative_pure(M.PSLUA_Effect_monadEffect.Applicative0(M.PSLUA_Prim_undefined))(fPrime(aPrime)) end) end) end end end)(), Functor0 = function(unused5) - return PSLUA_Effect_PSLUA_lazy_functorEffect(0) + return M.PSLUA_Effect_PSLUA_lazy_functorEffect(0) end } end) return { - main = PSLUA_Control_Applicative_pure(PSLUA_Effect_applicativeEffect)(nil) + main = M.PSLUA_Control_Applicative_pure(M.PSLUA_Effect_applicativeEffect)(nil) } diff --git a/test/ps/output/Golden.NameShadowing.Test/golden.lua b/test/ps/output/Golden.NameShadowing.Test/golden.lua index 62716e2..87eb34a 100644 --- a/test/ps/output/Golden.NameShadowing.Test/golden.lua +++ b/test/ps/output/Golden.NameShadowing.Test/golden.lua @@ -1,4 +1,5 @@ -PSLUA_Golden_NameShadowing_Test_f = function(v) +M = {} +M.PSLUA_Golden_NameShadowing_Test_f = function(v) return function(v1) if 1 == v then return 1 else if 1 == v1 then return 2 else return 3 end end end @@ -6,8 +7,8 @@ end return { b = function(x) return function(x1) - return PSLUA_Golden_NameShadowing_Test_f(PSLUA_Golden_NameShadowing_Test_f(x)(x1))(PSLUA_Golden_NameShadowing_Test_f(42)(1)) + return M.PSLUA_Golden_NameShadowing_Test_f(M.PSLUA_Golden_NameShadowing_Test_f(x)(x1))(M.PSLUA_Golden_NameShadowing_Test_f(42)(1)) end end, - c = PSLUA_Golden_NameShadowing_Test_f + c = M.PSLUA_Golden_NameShadowing_Test_f } diff --git a/test/ps/output/Golden.Nested.Test/golden.lua b/test/ps/output/Golden.Nested.Test/golden.lua index 7e15f64..72fd06f 100644 --- a/test/ps/output/Golden.Nested.Test/golden.lua +++ b/test/ps/output/Golden.Nested.Test/golden.lua @@ -1,17 +1,18 @@ -PSLUA_Golden_Nested_Test_isZero = function(v) +M = {} +M.PSLUA_Golden_Nested_Test_isZero = function(v) if 0 == v then return true else return false end end return { - isZero = PSLUA_Golden_Nested_Test_isZero, + isZero = M.PSLUA_Golden_Nested_Test_isZero, main = (function() - if PSLUA_Golden_Nested_Test_isZero(1) then - if PSLUA_Golden_Nested_Test_isZero(1) then + if M.PSLUA_Golden_Nested_Test_isZero(1) then + if M.PSLUA_Golden_Nested_Test_isZero(1) then return "ok" else return "fine" end else - if PSLUA_Golden_Nested_Test_isZero(0) then + if M.PSLUA_Golden_Nested_Test_isZero(0) then return "ha" else return "cool" diff --git a/test/ps/output/Golden.Newtype.Test/golden.lua b/test/ps/output/Golden.Newtype.Test/golden.lua index 04894e4..7864051 100644 --- a/test/ps/output/Golden.Newtype.Test/golden.lua +++ b/test/ps/output/Golden.Newtype.Test/golden.lua @@ -1,6 +1,7 @@ -PSLUA_Golden_Newtype_Test_NT = function(x) return x end +M = {} +M.PSLUA_Golden_Newtype_Test_NT = function(x) return x end return { - NT = PSLUA_Golden_Newtype_Test_NT, + NT = M.PSLUA_Golden_Newtype_Test_NT, f = function(v) return v.foo end, - g = PSLUA_Golden_Newtype_Test_NT + g = M.PSLUA_Golden_Newtype_Test_NT } diff --git a/test/ps/output/Golden.PatternMatching.Test2/golden.lua b/test/ps/output/Golden.PatternMatching.Test2/golden.lua index def6f5c..f110918 100644 --- a/test/ps/output/Golden.PatternMatching.Test2/golden.lua +++ b/test/ps/output/Golden.PatternMatching.Test2/golden.lua @@ -1,10 +1,11 @@ -local PSLUA_Golden_PatternMatching_Test2_bat -PSLUA_Golden_PatternMatching_Test2_bat = function(n) +M = {} +M.PSLUA_Golden_PatternMatching_Test2_bat = nil +M.PSLUA_Golden_PatternMatching_Test2_bat = function(n) if "Golden.PatternMatching.Test1∷N.Zero" == n["$ctor"] then return 1 else if "Golden.PatternMatching.Test1∷N.Succ" == n["$ctor"] then - return PSLUA_Golden_PatternMatching_Test2_bat(n.value0) + return M.PSLUA_Golden_PatternMatching_Test2_bat(n.value0) else return error("No patterns matched") end @@ -67,5 +68,5 @@ return { return 6 end end, - bat = PSLUA_Golden_PatternMatching_Test2_bat + bat = M.PSLUA_Golden_PatternMatching_Test2_bat } diff --git a/test/ps/output/Golden.RecDataDefs.Test/golden.lua b/test/ps/output/Golden.RecDataDefs.Test/golden.lua index b4aab71..454f266 100644 --- a/test/ps/output/Golden.RecDataDefs.Test/golden.lua +++ b/test/ps/output/Golden.RecDataDefs.Test/golden.lua @@ -1,19 +1,24 @@ -PSLUA_Golden_RecDataDefs_Test_A = { ["$ctor"] = "Golden.RecDataDefs.Test∷A.A" } -PSLUA_Golden_RecDataDefs_Test_AB = function(value0) +M = {} +M.PSLUA_Golden_RecDataDefs_Test_A = { + ["$ctor"] = "Golden.RecDataDefs.Test∷A.A" +} +M.PSLUA_Golden_RecDataDefs_Test_AB = function(value0) return { ["$ctor"] = "Golden.RecDataDefs.Test∷A.AB", value0 = value0 } end -PSLUA_Golden_RecDataDefs_Test_B = { ["$ctor"] = "Golden.RecDataDefs.Test∷B.B" } -PSLUA_Golden_RecDataDefs_Test_BA = function(value0) +M.PSLUA_Golden_RecDataDefs_Test_B = { + ["$ctor"] = "Golden.RecDataDefs.Test∷B.B" +} +M.PSLUA_Golden_RecDataDefs_Test_BA = function(value0) return { ["$ctor"] = "Golden.RecDataDefs.Test∷B.BA", value0 = value0 } end -PSLUA_Golden_RecDataDefs_Test_ab = PSLUA_Golden_RecDataDefs_Test_AB(PSLUA_Golden_RecDataDefs_Test_B) +M.PSLUA_Golden_RecDataDefs_Test_ab = M.PSLUA_Golden_RecDataDefs_Test_AB(M.PSLUA_Golden_RecDataDefs_Test_B) return { - A = PSLUA_Golden_RecDataDefs_Test_A, - AB = PSLUA_Golden_RecDataDefs_Test_AB, - B = PSLUA_Golden_RecDataDefs_Test_B, - BA = PSLUA_Golden_RecDataDefs_Test_BA, - a = PSLUA_Golden_RecDataDefs_Test_A, - b = PSLUA_Golden_RecDataDefs_Test_B, - ab = PSLUA_Golden_RecDataDefs_Test_ab, - ba = PSLUA_Golden_RecDataDefs_Test_BA(PSLUA_Golden_RecDataDefs_Test_ab) + A = M.PSLUA_Golden_RecDataDefs_Test_A, + AB = M.PSLUA_Golden_RecDataDefs_Test_AB, + B = M.PSLUA_Golden_RecDataDefs_Test_B, + BA = M.PSLUA_Golden_RecDataDefs_Test_BA, + a = M.PSLUA_Golden_RecDataDefs_Test_A, + b = M.PSLUA_Golden_RecDataDefs_Test_B, + ab = M.PSLUA_Golden_RecDataDefs_Test_ab, + ba = M.PSLUA_Golden_RecDataDefs_Test_BA(M.PSLUA_Golden_RecDataDefs_Test_ab) } diff --git a/test/ps/output/Golden.RecordsAccess.Test/golden.lua b/test/ps/output/Golden.RecordsAccess.Test/golden.lua index d5cc347..ade270d 100644 --- a/test/ps/output/Golden.RecordsAccess.Test/golden.lua +++ b/test/ps/output/Golden.RecordsAccess.Test/golden.lua @@ -1,7 +1,8 @@ -PSLUA_Golden_RecordsAccess_Test_r = { x = 1, y = true } +M = {} +M.PSLUA_Golden_RecordsAccess_Test_r = { x = 1, y = true } return { - r = PSLUA_Golden_RecordsAccess_Test_r, - test1 = PSLUA_Golden_RecordsAccess_Test_r.x, + r = M.PSLUA_Golden_RecordsAccess_Test_r, + test1 = M.PSLUA_Golden_RecordsAccess_Test_r.x, test2 = function(v) return v.x end, test3 = function(v) return v.x end, test4 = function(v) return v.x end diff --git a/test/ps/output/Golden.RecordsUpdate.Test/golden.lua b/test/ps/output/Golden.RecordsUpdate.Test/golden.lua index f01520b..faa87ba 100644 --- a/test/ps/output/Golden.RecordsUpdate.Test/golden.lua +++ b/test/ps/output/Golden.RecordsUpdate.Test/golden.lua @@ -1,3 +1,4 @@ +M = {} function PSLUA_object_update(o, patches) local o_copy = {} for k, v in pairs(o) do @@ -10,14 +11,14 @@ function PSLUA_object_update(o, patches) end return o_copy end -PSLUA_Golden_RecordsUpdate_Test_r = { +M.PSLUA_Golden_RecordsUpdate_Test_r = { x = 1, y = true, z = { z = "foo", p = "a" } } return { - r = PSLUA_Golden_RecordsUpdate_Test_r, - test1 = PSLUA_object_update(PSLUA_Golden_RecordsUpdate_Test_r, { x = 2 }), + r = M.PSLUA_Golden_RecordsUpdate_Test_r, + test1 = PSLUA_object_update(M.PSLUA_Golden_RecordsUpdate_Test_r, { x = 2 }), test2 = function(v) return PSLUA_object_update(v, { y = false }) end, test3 = function(v) return PSLUA_object_update(v, { z = PSLUA_object_update(v.z, { p = "b" }) }) diff --git a/test/ps/output/Golden.Unbinding.Test/golden.lua b/test/ps/output/Golden.Unbinding.Test/golden.lua index d47738a..0dc96d8 100644 --- a/test/ps/output/Golden.Unbinding.Test/golden.lua +++ b/test/ps/output/Golden.Unbinding.Test/golden.lua @@ -1,9 +1,10 @@ -PSLUA_Golden_Unbinding_Test_f = function(unused1) +M = {} +M.PSLUA_Golden_Unbinding_Test_f = function(unused1) return function(unused0) return 3 end end return { a = 1, b = 2, - f = PSLUA_Golden_Unbinding_Test_f, - c = PSLUA_Golden_Unbinding_Test_f(1)(PSLUA_Golden_Unbinding_Test_f(2)(1)) + f = M.PSLUA_Golden_Unbinding_Test_f, + c = M.PSLUA_Golden_Unbinding_Test_f(1)(M.PSLUA_Golden_Unbinding_Test_f(2)(1)) } diff --git a/test/ps/packages.dhall b/test/ps/packages.dhall index 4a4a94e..0327fc0 100644 --- a/test/ps/packages.dhall +++ b/test/ps/packages.dhall @@ -1,15 +1,10 @@ -let upstream = - https://github.com/Unisay/purescript-lua-package-sets/releases/download/psc-0.15.15-20240321/packages.dhall - sha256:5b0a1f05293f3dfc6de9e2d87c5afab1cac35e2d9b38693f032f3e9a86a1090d +let upstream-ps = + https://github.com/purescript/package-sets/releases/download/psc-0.15.15-20240419/packages.dhall + sha256:50c4ee579bf2c38671ac97df821c2cc4221fb3f6ad79c807bb6e4597ab6d1e95 + +let upstream-lua = + https://github.com/Unisay/purescript-lua-package-sets/releases/download/psc-0.15.15-20240416/packages.dhall + sha256:e68b7752ca4dee0f0578a2e40159caf6d1290a711777931b20d10d807823b52d + +in upstream-ps // upstream-lua -in upstream - with effect = - { dependencies = [ "prelude" ] - , repo = "https://github.com/Unisay/purescript-lua-effect.git" - , version = "v4.1.0" - } - with prelude = - { dependencies = [] : List Text - , repo = "https://github.com/Unisay/purescript-lua-prelude.git" - , version = "v7.1.0" - }