diff --git a/bench/goldens/fnew_Bench.EffectStep.txt b/bench/goldens/fnew_Bench.EffectStep.txt index c6be304a..725cf89b 100644 --- a/bench/goldens/fnew_Bench.EffectStep.txt +++ b/bench/goldens/fnew_Bench.EffectStep.txt @@ -5,14 +5,14 @@ function-body FNEW: 11 total FNEW: 22 prototypes: 23 function-body FNEW sites: - Bench.EffectStep.lua:4 - Bench.EffectStep.lua:6 - Bench.EffectStep.lua:6 + Bench.EffectStep.lua:3 + Bench.EffectStep.lua:5 + Bench.EffectStep.lua:5 + Bench.EffectStep.lua:8 Bench.EffectStep.lua:9 - Bench.EffectStep.lua:10 - Bench.EffectStep.lua:12 - Bench.EffectStep.lua:12 - Bench.EffectStep.lua:33 - Bench.EffectStep.lua:44 - Bench.EffectStep.lua:47 - Bench.EffectStep.lua:56 + Bench.EffectStep.lua:11 + Bench.EffectStep.lua:11 + Bench.EffectStep.lua:32 + Bench.EffectStep.lua:43 + Bench.EffectStep.lua:46 + Bench.EffectStep.lua:55 diff --git a/bench/goldens/fnew_Bench.RefLoop.txt b/bench/goldens/fnew_Bench.RefLoop.txt index 31384f3f..9260169a 100644 --- a/bench/goldens/fnew_Bench.RefLoop.txt +++ b/bench/goldens/fnew_Bench.RefLoop.txt @@ -5,15 +5,15 @@ function-body FNEW: 12 total FNEW: 20 prototypes: 21 function-body FNEW sites: - Bench.RefLoop.lua:6 - Bench.RefLoop.lua:6 - Bench.RefLoop.lua:9 - Bench.RefLoop.lua:9 - Bench.RefLoop.lua:17 + Bench.RefLoop.lua:5 + Bench.RefLoop.lua:5 + Bench.RefLoop.lua:8 + Bench.RefLoop.lua:8 Bench.RefLoop.lua:16 Bench.RefLoop.lua:15 + Bench.RefLoop.lua:14 + Bench.RefLoop.lua:18 Bench.RefLoop.lua:19 - Bench.RefLoop.lua:20 - Bench.RefLoop.lua:28 Bench.RefLoop.lua:27 - Bench.RefLoop.lua:41 + Bench.RefLoop.lua:26 + Bench.RefLoop.lua:40 diff --git a/bench/goldens/fnew_Bench.StateStep.txt b/bench/goldens/fnew_Bench.StateStep.txt index 2d95f35f..d9959869 100644 --- a/bench/goldens/fnew_Bench.StateStep.txt +++ b/bench/goldens/fnew_Bench.StateStep.txt @@ -5,4 +5,4 @@ function-body FNEW: 1 total FNEW: 4 prototypes: 5 function-body FNEW sites: - Bench.StateStep.lua:9 + Bench.StateStep.lua:6 diff --git a/bench/goldens/tnew_Bench.EffectStep.txt b/bench/goldens/tnew_Bench.EffectStep.txt index 6867db9b..1e844521 100644 --- a/bench/goldens/tnew_Bench.EffectStep.txt +++ b/bench/goldens/tnew_Bench.EffectStep.txt @@ -1,8 +1,8 @@ chunk: Bench.EffectStep.lua runtime: LuaJIT 2.1.1741730670 -main-chunk TNEW+TDUP: 4 +main-chunk TNEW+TDUP: 3 function-body TNEW+TDUP: 1 -total TNEW+TDUP: 5 +total TNEW+TDUP: 4 prototypes: 23 function-body TNEW+TDUP sites: - Bench.EffectStep.lua:9 TDUP + Bench.EffectStep.lua:8 TDUP diff --git a/bench/goldens/tnew_Bench.RefLoop.txt b/bench/goldens/tnew_Bench.RefLoop.txt index 81cc5967..156b2da8 100644 --- a/bench/goldens/tnew_Bench.RefLoop.txt +++ b/bench/goldens/tnew_Bench.RefLoop.txt @@ -1,8 +1,8 @@ chunk: Bench.RefLoop.lua runtime: LuaJIT 2.1.1741730670 -main-chunk TNEW+TDUP: 5 +main-chunk TNEW+TDUP: 4 function-body TNEW+TDUP: 1 -total TNEW+TDUP: 6 +total TNEW+TDUP: 5 prototypes: 21 function-body TNEW+TDUP sites: - Bench.RefLoop.lua:19 TDUP + Bench.RefLoop.lua:18 TDUP diff --git a/bench/goldens/tnew_Bench.StateStep.txt b/bench/goldens/tnew_Bench.StateStep.txt index f6ce375d..a45c70d7 100644 --- a/bench/goldens/tnew_Bench.StateStep.txt +++ b/bench/goldens/tnew_Bench.StateStep.txt @@ -1,7 +1,7 @@ chunk: Bench.StateStep.lua runtime: LuaJIT 2.1.1741730670 -main-chunk TNEW+TDUP: 2 +main-chunk TNEW+TDUP: 1 function-body TNEW+TDUP: 0 -total TNEW+TDUP: 2 +total TNEW+TDUP: 1 prototypes: 5 function-body TNEW+TDUP sites: diff --git a/bench/goldens/trace_effect_step.txt b/bench/goldens/trace_effect_step.txt index 99afc096..f53dd352 100644 --- a/bench/goldens/trace_effect_step.txt +++ b/bench/goldens/trace_effect_step.txt @@ -2,19 +2,19 @@ spec: effect_step runtime: LuaJIT 2.1.1741730670 workload: n=100000 reps=4 result=1500000 aborts (distinct site -- reason): - Bench.EffectStep.lua:10 -- NYI: bytecode FNEW - Bench.EffectStep.lua:12 -- NYI: bytecode FNEW - Bench.EffectStep.lua:44 -- NYI: bytecode FNEW - Bench.EffectStep.lua:56 -- NYI: bytecode FNEW + Bench.EffectStep.lua:11 -- NYI: bytecode FNEW + Bench.EffectStep.lua:43 -- NYI: bytecode FNEW + Bench.EffectStep.lua:55 -- NYI: bytecode FNEW + Bench.EffectStep.lua:8 -- NYI: bytecode FNEW Bench.EffectStep.lua:9 -- NYI: bytecode FNEW bytecode end state (J*=compiled, I*=blacklisted): Bench.EffectStep.lua:10 IFUNCF - Bench.EffectStep.lua:10 JFUNCF Bench.EffectStep.lua:11 IFUNCF - Bench.EffectStep.lua:12 IFUNCF - Bench.EffectStep.lua:12 JFUNCF - Bench.EffectStep.lua:17 IFUNCF + Bench.EffectStep.lua:11 JFUNCF + Bench.EffectStep.lua:16 IFUNCF + Bench.EffectStep.lua:35 IFUNCF Bench.EffectStep.lua:36 IFUNCF - Bench.EffectStep.lua:37 IFUNCF + Bench.EffectStep.lua:8 JFUNCF + Bench.EffectStep.lua:9 IFUNCF Bench.EffectStep.lua:9 JFUNCF counts: aborts=5 compiled=3 blacklisted=6 diff --git a/bench/goldens/trace_ref_loop.txt b/bench/goldens/trace_ref_loop.txt index ba0c3bfd..38f06c59 100644 --- a/bench/goldens/trace_ref_loop.txt +++ b/bench/goldens/trace_ref_loop.txt @@ -2,9 +2,10 @@ spec: ref_loop runtime: LuaJIT 2.1.1741730670 workload: n=100000 reps=4 result=4999950000 aborts (distinct site -- reason): - Bench.RefLoop.lua:41 -- NYI: bytecode FNEW + Bench.RefLoop.lua:40 -- NYI: bytecode FNEW bytecode end state (J*=compiled, I*=blacklisted): - Bench.RefLoop.lua:11 JFUNCF - Bench.RefLoop.lua:35 JFORI - Bench.RefLoop.lua:35 JFORL -counts: aborts=1 compiled=3 blacklisted=0 + Bench.RefLoop.lua:10 JFUNCF + Bench.RefLoop.lua:32 JFUNCF + Bench.RefLoop.lua:34 JFORI + Bench.RefLoop.lua:34 JFORL +counts: aborts=1 compiled=4 blacklisted=0 diff --git a/bench/goldens/trace_state_step.txt b/bench/goldens/trace_state_step.txt index 808a4d41..e6782cfd 100644 --- a/bench/goldens/trace_state_step.txt +++ b/bench/goldens/trace_state_step.txt @@ -2,10 +2,10 @@ spec: state_step runtime: LuaJIT 2.1.1741730670 workload: n=100000 reps=4 result=99998 aborts (distinct site -- reason): - Bench.StateStep.lua:9 -- NYI: bytecode FNEW + Bench.StateStep.lua:6 -- NYI: bytecode FNEW bytecode end state (J*=compiled, I*=blacklisted): - Bench.StateStep.lua:13 IFUNCF - Bench.StateStep.lua:35 ILOOP - Bench.StateStep.lua:4 IFUNCF - Bench.StateStep.lua:5 JFUNCF + Bench.StateStep.lua:1 IFUNCF + Bench.StateStep.lua:2 JFUNCF + Bench.StateStep.lua:30 ILOOP + Bench.StateStep.lua:8 IFUNCF counts: aborts=1 compiled=1 blacklisted=3 diff --git a/changelog.d/20260728_210000_unisay_inline_single_use_foreign_import.md b/changelog.d/20260728_210000_unisay_inline_single_use_foreign_import.md new file mode 100644 index 00000000..03568992 --- /dev/null +++ b/changelog.d/20260728_210000_unisay_inline_single_use_foreign_import.md @@ -0,0 +1,25 @@ +### Changed + +- A foreign module's export table is no longer kept hoisted when exactly one + once-evaluated site reads it (#251). The compiler binds each FFI module's + exports to one `ForeignImport` table and reads individual names off it, and + it used to refuse to fold that table into its reader however few readers + there were, because an export value can be a Lua table constructor with + identity (`unit = {}`) that a copy under a lambda would re-allocate per call. + A new late pass admits the cases where re-evaluation provably cannot happen: + one reference, a header-free FFI source (a bare `return { … }`, so nothing + side-effecting moves), and a path from the enclosing top-level right-hand + side to that reference crossing only positions evaluated exactly once — never + a lambda body, an `if` branch, or the right operand of `and`/`or`. The + emitted Lua then loses a table allocation and a hash read per folded import: + `local M_foreign = { token = {} }` plus `return { token = M_foreign.token }` + becomes `return { token = {} }`, and a shared accessor collapses in place + from `local M_log = M_foreign.log` to + `local M_log = function(s) return function() print(s) end end`. + +- The pass runs directly after the accessor-sharing pass (#248), which is the + last one to change how many references an import has — dissolving an accessor + multiplies them over the use sites, re-binding a shared read collapses them + back to one. That placement is what lets it catch both shapes the fold has: + the read dissolved into an export expression, and the accessor binding kept + as a shared name whose right-hand side is the import's only reference. diff --git a/lib/Language/PureScript/Backend.hs b/lib/Language/PureScript/Backend.hs index d9b66692..4ef2c708 100644 --- a/lib/Language/PureScript/Backend.hs +++ b/lib/Language/PureScript/Backend.hs @@ -9,7 +9,8 @@ import Language.PureScript.Backend.IR.Inliner qualified as Inliner import Language.PureScript.Backend.IR.Linker qualified as Linker import Language.PureScript.Backend.IR.Linter qualified as Linter import Language.PureScript.Backend.IR.Optimizer - ( optimizedUberModule + ( ProgramFacts (..) + , optimizedUberModule , optimizedUberModuleChecked ) import Language.PureScript.Backend.IR.Pass @@ -59,10 +60,14 @@ compileModules outputDir foreignDir lintIR limits directives appOrModule = do -- the whole pipeline can see through them (issue #178). DCE later prunes the -- foreign source rows thus lifted away. liftedModule ← ForeignLift.liftForeigns foreignDir linkedModule + -- See Note [Inlining a single-use foreign import] + factsHeaderFreeForeigns ← + liftIO (ForeignLift.headerFreeForeigns foreignDir liftedModule) + let facts = ProgramFacts {factsDataTypes = dataDecls, factsHeaderFreeForeigns} uberModule ← if untag lintIR - then Oops.hoistEither (optimizedUberModuleChecked dataDecls liftedModule) - else pure (optimizedUberModule dataDecls liftedModule) + then Oops.hoistEither (optimizedUberModuleChecked facts liftedModule) + else pure (optimizedUberModule facts liftedModule) -- A dangling imported reference compiles to a read of a never-assigned -- module-table field — a nil call at runtime — so refuse to emit code for -- it (issue #297). Unconditional, unlike the per-pass linting behind diff --git a/lib/Language/PureScript/Backend/IR/Inliner.hs b/lib/Language/PureScript/Backend/IR/Inliner.hs index 9df7d5e6..abdb1a90 100644 --- a/lib/Language/PureScript/Backend/IR/Inliner.hs +++ b/lib/Language/PureScript/Backend/IR/Inliner.hs @@ -103,14 +103,17 @@ foreign bodies are the exception: @always@ itself, because they exist to beta-reduce at saturated call sites. The 'ForeignImport' expression itself — the table of a foreign module's -exports — is the one shape the optimizer refuses to inline even when it is +exports — is the one shape the inliner refuses to paste even when it is referenced exactly once. Its export values are opaque to the IR, and some of them are Lua table constructors with identity (e.g. @unit = {}@ in the prelude), so pasting the import into its use site — possibly under a lambda — would re-evaluate the foreign source per call and allocate fresh tables where every site is supposed to share one. The table stays hoisted as a single -binding and the always-inlined 'ObjectProp' wrappers turn into field reads -off it. +binding and the 'ObjectProp' wrappers turn into field reads off it. One late +pass admits the cases where the re-evaluation provably cannot happen: +'Language.PureScript.Backend.IR.Optimizer.inlineSingleUseForeignImports' +dissolves an import that a header-free FFI source produced and that a single +once-evaluated site reads (see Note [Inlining a single-use foreign import]). -} -------------------------------------------------------------------------------- diff --git a/lib/Language/PureScript/Backend/IR/Optimizer.hs b/lib/Language/PureScript/Backend/IR/Optimizer.hs index 3244afdf..76c8924a 100644 --- a/lib/Language/PureScript/Backend/IR/Optimizer.hs +++ b/lib/Language/PureScript/Backend/IR/Optimizer.hs @@ -96,29 +96,46 @@ import Language.PureScript.Backend.IR.Types import Language.PureScript.Backend.IR.Uncurry (uncurryWorkerWrapper) import Language.PureScript.Backend.IR.Uniquify (uniquifyNames) -optimizedUberModule ∷ DataTypes → UberModule → UberModule -optimizedUberModule dataTypes uber = runSupply do +{- | What the optimizer knows about the program beyond the IR it is handed: +the data-type table collected from CoreFn +('Language.PureScript.Backend.IR.collectDataDeclarations'), read by the +exhaustiveness-driven rewrite ('removeUnreachableMatchDefault'), and the +foreign modules whose FFI source is header-free +('Language.PureScript.Backend.Lua.ForeignLift.headerFreeForeigns'), read by +the single-use foreign-import fold (Note [Inlining a single-use foreign +import]). Both are facts the IR itself does not carry, so the caller supplies +them; 'mempty' asserts neither, and the rules that read them decline. +-} +data ProgramFacts = ProgramFacts + { factsDataTypes ∷ DataTypes + , factsHeaderFreeForeigns ∷ Set ModuleName + } + deriving stock (Generic) + deriving (Semigroup, Monoid) via Generically ProgramFacts + +optimizedUberModule ∷ ProgramFacts → UberModule → UberModule +optimizedUberModule facts uber = runSupply do let policy = collectInlinePolicy uber - settled ← runSteps (settlePhase (optimizerPipeline dataTypes policy)) uber + settled ← runSteps (settlePhase (optimizerPipeline facts policy)) uber -- See Note [Derived inline directives] let extended = policy <> derivedInlinePolicy policy settled - runSteps (lowerPhase (optimizerPipeline dataTypes extended)) settled + runSteps (lowerPhase (optimizerPipeline facts extended)) settled {- | 'optimizedUberModule' with every pass's contract checked by the linter, failing with the name of the offending pass. Used by the test suite always, and by the CLI behind the @--lint-ir@ flag. -} optimizedUberModuleChecked - ∷ DataTypes → UberModule → Either PassCheckFailure UberModule -optimizedUberModuleChecked dataTypes uber = runSupply $ runExceptT do + ∷ ProgramFacts → UberModule → Either PassCheckFailure UberModule +optimizedUberModuleChecked facts uber = runSupply $ runExceptT do let policy = collectInlinePolicy uber settled ← ExceptT - (runStepsChecked (settlePhase (optimizerPipeline dataTypes policy)) uber) + (runStepsChecked (settlePhase (optimizerPipeline facts policy)) uber) -- See Note [Derived inline directives] let extended = policy <> derivedInlinePolicy policy settled ExceptT - (runStepsChecked (lowerPhase (optimizerPipeline dataTypes extended)) settled) + (runStepsChecked (lowerPhase (optimizerPipeline facts extended)) settled) {- | The optimizer pipeline, split at the directive-derivation point: the settle phase brings every binding to the shape @@ -131,19 +148,18 @@ data OptimizerPhases = OptimizerPhases , lowerPhase ∷ [Step] } -{- | The IR optimization pipeline. The first argument is the data-type -table collected from CoreFn ('collectDataDeclarations'), consulted by -the exhaustiveness-driven rewrite ('removeUnreachableMatchDefault'); -the second is the inlining policy collected once from the pristine -module before any pass runs: later rewrites may strip annotations, so -every directive keys off a name (see Note [Inline annotations and -inlining heuristics]). The result is phase-split so the caller can -extend the policy with derived directives between the phases -('OptimizerPhases'). --} -optimizerPipeline ∷ DataTypes → InlinePolicy → OptimizerPhases -optimizerPipeline dataTypes policy = OptimizerPhases {settlePhase, lowerPhase} +{- | The IR optimization pipeline. The first argument is what the caller +knows about the program beyond the IR ('ProgramFacts'); the second is the +inlining policy collected once from the pristine module before any pass +runs: later rewrites may strip annotations, so every directive keys off a +name (see Note [Inline annotations and inlining heuristics]). The result +is phase-split so the caller can extend the policy with derived +directives between the phases ('OptimizerPhases'). +-} +optimizerPipeline ∷ ProgramFacts → InlinePolicy → OptimizerPhases +optimizerPipeline facts policy = OptimizerPhases {settlePhase, lowerPhase} where + ProgramFacts {factsDataTypes = dataTypes, factsHeaderFreeForeigns} = facts settlePhase = [ -- The entry pass (issue #139): establishes the global-uniqueness -- condition (GUC = 'UniqueBinders') that every @@ -237,6 +253,14 @@ optimizerPipeline dataTypes policy = OptimizerPhases {settlePhase, lowerPhase} -- the last pass that can multiply reads and before the final -- flattening. See 'shareForeignAccessors'. RunPass shareAccessorsPass + , -- Dissolve the foreign table of a header-free FFI module read at a + -- single, once-evaluated site into that site. Runs directly after + -- share-accessors, the last pass that moves a foreign read: only + -- here is the reference count of an import final, and only here + -- does the accessor a shared read was just re-bound to count as + -- the import's one reference. See Note [Inlining a single-use + -- foreign import]. + RunPass inlineSingleUseForeignsPass , -- Rebuild sharing within one body for the pure repeats the pastes -- above left behind (issue #183): alpha-equivalent effect-free -- subexpressions of a block are hoisted into a shared Let. Runs @@ -339,6 +363,10 @@ optimizerPipeline dataTypes policy = OptimizerPhases {settlePhase, lowerPhase} floatInPass = gucPass "float-in" floatIn shareAccessorsPass = gucPass "share-accessors" (shareForeignAccessors policy) + inlineSingleUseForeignsPass = + gucPass + "inline-single-use-foreigns" + (inlineSingleUseForeignImports factsHeaderFreeForeigns) csePass = Pass { passName = "cse" @@ -494,6 +522,182 @@ shareForeignAccessors policy uber ] grouping → [grouping] +{- Note [Inlining a single-use foreign import] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +A 'ForeignImport' is the table of one foreign module's exports, and the +inliner refuses to paste one into its use sites however few they are +(Note [Inline annotations and inlining heuristics]): the export values are +opaque to the IR and some are Lua table constructors with identity +(@unit = {}@ in the prelude), so a copy landing under a lambda would +allocate a fresh table per call where every site is meant to share one. + +'inlineSingleUseForeignImports' admits the shapes where that cannot happen. +It folds an import into its use site when + + (1) exactly one reference to the import is left; + (2) its FFI source is header-free — a bare @return { … }@ with nothing + before it (Note [Foreign module source format] in + "Language.PureScript.Backend.Lua.Linker.Foreign", decided by + 'Language.PureScript.Backend.Lua.ForeignLift.headerFreeForeigns'); + (3) the path from the top-level right-hand side (or export) holding that + reference down to it crosses only positions evaluated exactly once + per evaluation of the root ('evaluatedExactlyOnce'). + +Identity is minted per evaluation of the constructor, so preserving the +number of evaluations preserves identity: (1) and (3) together say the +table is still built exactly once after the fold. (2) is about /when/ it +is built — header statements may carry side effects whose order against +the other module-init statements the fold would move, whereas a +header-free source lowers to a plain table constructor whose evaluation +commutes with them. + +Every top-level right-hand side and export is a once-evaluated root, since +module init runs each exactly once, so the walk starts there and declines +at an 'AbsN' (a body runs zero to many times per evaluation of the lambda, +and an IR thunk is a lambda, so laziness is covered by the same test), at +either branch of an 'IfThenElse', and at the right operand of Lua's +short-circuiting @and@/@or@ (zero or one). + +The pass runs directly after 'shareForeignAccessors' because that is the +last pass to change an import's reference count, and it moves the count in +both directions: dissolving an accessor multiplies the import's references +over the use sites, and re-binding a read shared by several sites +collapses them back to one — the accessor binding's right-hand side, which +is a once-evaluated root. Nothing further happens at the IR level; the +payoff is in the Lua backend, where the pasted import lowers to a field +access into a table constructor that 'reduceTableDefinitionAccessor' +(issue #140) and the scope-call fold (issue #159) reduce to the field's +value. + +That last fold keeps one row and discards the rest, so a name still on the +folded import's list but no longer read loses its allocation — the shape +left behind when the last reader of a second export disappears after +'mergeForeignsIntoBindings', past the point where dead-code elimination +re-prunes the list. Dropping the row is the same licence dead-code +elimination already takes when it prunes an unreferenced name out of a +hoisted import, and it is why an FFI file's effects belong in its header, +which condition (2) keeps out of the fold altogether. +-} + +{- | Fold a foreign module's export table into the single, once-evaluated +site that reads it. See Note [Inlining a single-use foreign import]; the +argument is the set of modules whose FFI source is header-free. +-} +inlineSingleUseForeignImports ∷ Set ModuleName → UberModule → UberModule +inlineSingleUseForeignImports headerFree uber + | Map.null folded = uber + | otherwise = + uber + { uberModuleBindings = + [ fmap (fmap pasteImports) grouping + | grouping ← uberModuleBindings + , not (dissolved grouping) + ] + , uberModuleExports = fmap (fmap pasteImports) uberModuleExports + } + where + UberModule {uberModuleBindings, uberModuleExports} = uber + + -- The linker never puts an import in a recursive group, so only a + -- 'Standalone' binding can be the one the paste replaces. + dissolved ∷ Grouping (QName, Exp) → Bool + dissolved = \case + Standalone (qname, _rhs) → qname `Map.member` folded + RecursiveGroup {} → False + + -- Every top-level right-hand side and export: the once-evaluated roots + -- the reference must be reachable from, and the sites the fold rewrites. + roots ∷ [Exp] + roots = + (snd <$> (listGrouping =<< uberModuleBindings)) + <> (snd <$> uberModuleExports) + + referenceCounts ∷ Map (Qualified Name) Natural + referenceCounts = Map.unionsWith (+) (countFreeRefs <$> roots) + + -- The imports to dissolve, keyed by the name their binding holds. An + -- import's right-hand side names nothing, so no folded import can occur + -- inside another and the pastes are independent of each other. + folded ∷ Map QName Exp + folded = + Map.fromList + [ (qname, expr) + | Standalone (qname, expr@(ForeignImport _ann modname _path _names)) ← + uberModuleBindings + , modname `Set.member` headerFree + , let ref = qualifiedQName qname + , Map.lookup ref referenceCounts == Just 1 + , all (evaluatedExactlyOnce ref) roots + ] + + pasteImports ∷ Exp → Exp + pasteImports = transformOf subexpressions \node → case node of + Ref _ann (Imported modname name) → + fromMaybe node (Map.lookup (QName modname name) folded) + _ → node + +{- | Whether every free occurrence of the name within the expression sits +in a position evaluated exactly once per evaluation of the expression. +See Note [Inlining a single-use foreign import]. +-} +evaluatedExactlyOnce ∷ Qualified Name → Exp → Bool +evaluatedExactlyOnce name = go + where + go ∷ Exp → Bool + go expr + | occurrences expr == 0 = True + | Ref {} ← expr = True + | otherwise = + let children = onceEvaluatedSubexpressions expr + in sum (occurrences <$> children) == occurrences expr + && all go children + + occurrences ∷ Exp → Natural + occurrences = countFreeRef name + +{- | The subexpressions a node evaluates exactly once per evaluation of +itself. The complement — a lambda body, an 'IfThenElse' branch, the right +operand of Lua's short-circuiting @and@/@or@ — is evaluated zero to many +times and is therefore absent, which is how 'evaluatedExactlyOnce' spots a +reference it must not move. See Note [Inlining a single-use foreign +import]. +-} +onceEvaluatedSubexpressions ∷ RawExp ann → [RawExp ann] +onceEvaluatedSubexpressions = \case + LiteralInt {} → [] + LiteralFloat {} → [] + LiteralString {} → [] + LiteralChar {} → [] + LiteralBool {} → [] + LiteralArray _ann elems → elems + LiteralObject _ann props → snd <$> props + Ctor _ann _algTy _modname _tyName _ctorName fields → fields + ReflectCtor _ann e → [e] + Eq _ann a b → [a, b] + PrimBinOp _ann op a b + | op == PrimAnd || op == PrimOr → [a] + | otherwise → [a, b] + PrimNot _ann e → [e] + DataArgumentByIndex _ann _algTy _idx e → [e] + PrimLen _ann e → [e] + ArrayIndex _ann e _idx → [e] + ObjectProp _ann e _prop → [e] + ObjectUpdate _ann e props → e : (snd <$> toList props) + AbsN {} → [] + AppN _ann f args → f : toList args + Ref {} → [] + Let _ann groupings body → + [ rhs + | grouping ← toList groupings + , (_bindAnn, _name, rhs) ← listGrouping grouping + ] + <> [body] + Values _ann es → toList es + LetValues _ann _params rhs body → [rhs, body] + IfThenElse _ann cond _then _else → [cond] + Exception {} → [] + ForeignImport {} → [] + {- | Every inlining directive of the module, keyed by binding name. Collected once from the pristine module: later rewrites can drop an annotation off its node (e.g. constant folding replaces a binding's root diff --git a/lib/Language/PureScript/Backend/Lua/ForeignLift.hs b/lib/Language/PureScript/Backend/Lua/ForeignLift.hs index 0bdef517..d094c9b3 100644 --- a/lib/Language/PureScript/Backend/Lua/ForeignLift.hs +++ b/lib/Language/PureScript/Backend/Lua/ForeignLift.hs @@ -81,6 +81,7 @@ string/char literals — leaves the export opaque (correct for e.g. module Language.PureScript.Backend.Lua.ForeignLift ( liftForeigns , liftExport + , headerFreeForeigns , allowlist , Error (..) ) where @@ -317,6 +318,36 @@ liftForeigns , qname `Set.member` allowlist ] +{- | The foreign modules of a linked module whose FFI source is /header-free/: +its Lua chunk is a bare @return { … }@ with no statements before it (see +Note [Foreign module source format] in +"Language.PureScript.Backend.Lua.Linker.Foreign"). Such an import lowers to a +plain table constructor rather than a scope call wrapping header statements, +which is what lets the optimizer move it — see +Note [Inlining a single-use foreign import] in +"Language.PureScript.Backend.IR.Optimizer", the one consumer. + +A source that cannot be resolved or parsed is reported as not header-free +rather than as an error: the scan runs before dead-code elimination, so it +sees FFI files belonging to imports the pipeline later drops and never +compiles. The imports that do survive are parsed again when they are lowered +('Language.PureScript.Backend.Lua.fromIR'), which is where a broken file the +build actually needs is reported. +-} +headerFreeForeigns + ∷ Tagged "foreign" (Path Abs Dir) → UberModule → IO (Set ModuleName) +headerFreeForeigns foreignDir UberModule {uberModuleForeigns} = + foldMap headerFree + <$> sequence + [ (modname,) <$> Foreign.parseForeignSource (untag foreignDir) path + | (_qname, ForeignImport _ann modname path _names) ← uberModuleForeigns + ] + where + headerFree ∷ (ModuleName, Either Foreign.Error Source) → Set ModuleName + headerFree = \case + (modname, Right Source {header = []}) → Set.singleton modname + _ → Set.empty + -- | Lift a single accessor, given the already-parsed sources. liftAccessor ∷ Map ModuleName Source → QName → Maybe Exp liftAccessor sources QName {qnameModuleName, qnameName} = do diff --git a/test/Language/PureScript/Backend/IR/Optimizer/Spec.hs b/test/Language/PureScript/Backend/IR/Optimizer/Spec.hs index 4cdee378..9e07505d 100644 --- a/test/Language/PureScript/Backend/IR/Optimizer/Spec.hs +++ b/test/Language/PureScript/Backend/IR/Optimizer/Spec.hs @@ -2,6 +2,7 @@ module Language.PureScript.Backend.IR.Optimizer.Spec where import Control.Lens (toListOf) import Data.Map qualified as Map +import Data.Set qualified as Set import Data.Text qualified as Text import Hedgehog (PropertyT, annotateShow, diff, evalEither, forAll, (===)) import Hedgehog.Gen qualified as Gen @@ -19,6 +20,7 @@ import Language.PureScript.Backend.IR.Linter ) import Language.PureScript.Backend.IR.Names ( CtorName (..) + , ModuleName , Name (..) , PropName (..) , QName (..) @@ -28,6 +30,7 @@ import Language.PureScript.Backend.IR.Names ) import Language.PureScript.Backend.IR.Optimizer ( CallSiteInlining (SkipCallSites) + , ProgramFacts (..) , optimizeModule , optimizedExpression , optimizedExpressionWithCanon @@ -107,6 +110,14 @@ import Test.Hspec import Test.Hspec.Hedgehog (hedgehog, modifyMaxShrinks, modifyMaxSuccess) import Test.Hspec.Hedgehog.Extended (test) +{- | 'ProgramFacts' asserting that one module's FFI source is header-free, +the precondition of the single-use foreign-import fold (see Note [Inlining +a single-use foreign import]). +-} +headerFreeFacts ∷ ModuleName → ProgramFacts +headerFreeFacts modname = + mempty {factsHeaderFreeForeigns = Set.singleton modname} + -- | Like 'test', but runs the property over many generated inputs. prop ∷ String → PropertyT IO () → SpecWith () prop title = @@ -3571,7 +3582,9 @@ spec = describe "IR Optimizer" do -- identity, e.g. `unit = {}`) are invisible to the IR, so pasting the -- 'ForeignImport' into its use site can multiply allocations and -- change identity. Here the only use sits under a lambda: inlining - -- would re-create the table on every call. + -- would re-create the table on every call, so it stays hoisted even + -- with the source declared header-free — the one condition the + -- single-use fold cannot waive. test "does not inline a used-once foreign import" do let mainModule = moduleNameFromString "Main" original = @@ -3591,7 +3604,7 @@ spec = describe "IR Optimizer" do , modulePath = "Main.purs" } optimized = - optimizedUberModule mempty $ + optimizedUberModule (headerFreeFacts mainModule) $ Linker.makeUberModule (LinkAsModule mainModule) [original] foreignKept = [ qn @@ -3601,6 +3614,125 @@ spec = describe "IR Optimizer" do annotateShow optimized foreignKept === [QName mainModule (Name "foreign")] + describe "dissolves a single-use foreign import (issue #251)" do + -- A header-free FFI source is a bare `return { … }`, so its import + -- lowers to a plain table constructor whose evaluation may move + -- freely among the module-init statements. Read exactly once, from a + -- position evaluated exactly once, it is folded into that read: the + -- table is still built once, and the Lua backend takes the field out + -- of the constructor. + let mainModule = moduleNameFromString "Main" + foreignQName = QName mainModule Linker.foreignName + -- The linker's foreign shapes for a module declaring `x` (and, + -- with two names, `y`): see Note [Foreign bindings structure + -- emitted by the Linker]. + moduleWith + ∷ [(Ann, Name)] → [Grouping (Ann, Name, Exp)] → [Name] → Module + moduleWith foreigns bindings exports = + Module + { moduleName = mainModule + , moduleBindings = bindings + , moduleImports = [] + , moduleExports = exports + , moduleReExports = Map.empty + , moduleForeigns = foreigns + , modulePath = "Main.purs" + } + optimizeWith ∷ ProgramFacts → Module → Linker.UberModule + optimizeWith facts = + optimizedUberModule facts + . Linker.makeUberModule (LinkAsModule mainModule) + . pure + importsKept ∷ Linker.UberModule → [QName] + importsKept optimized = + [ qn + | Standalone (qn, ForeignImport {}) ← + Linker.uberModuleBindings optimized + ] + -- The import as the linker builds it, carrying the one reachable + -- name and the pragma declared on it. + theImport ∷ Ann → Exp + theImport nameAnn = + ForeignImport noAnn mainModule "Main.purs" [(nameAnn, Name "x")] + + test "folds the import into the export that reads it" do + -- `foreign import x` re-exported: the accessor dissolves into the + -- export, leaving the import read once at the export's root. + let optimized = + optimizeWith + (headerFreeFacts mainModule) + (moduleWith [(noAnn, Name "x")] [] [Name "x"]) + annotateShow optimized + Linker.uberModuleBindings optimized === [] + Linker.uberModuleExports optimized + === [(Name "x", objectProp (theImport noAnn) (PropName "x"))] + + test "collapses the import into a kept accessor binding" do + -- `@inline never` keeps the accessor a shared binding, whose + -- right-hand side is then the import's one reference — itself a + -- once-evaluated root, so the pair collapses into one binding. + let optimized = + optimizeWith + (headerFreeFacts mainModule) + (moduleWith [(Just Never, Name "x")] [] [Name "x"]) + annotateShow optimized + Linker.uberModuleBindings optimized + === [ Standalone + ( QName mainModule (Name "x") + , setAnn + (Just Never) + (objectProp (theImport (Just Never)) (PropName "x")) + ) + ] + + test "keeps an import whose source has header statements" do + -- Absent from the header-free set: the header's side effects would + -- move against the other module-init statements. + let optimized = + optimizeWith mempty (moduleWith [(noAnn, Name "x")] [] [Name "x"]) + annotateShow optimized + importsKept optimized === [foreignQName] + + test "keeps an import read at two sites" do + -- Two foreign names dissolve into two reads of the table; folding + -- either would duplicate the constructor. + let optimized = + optimizeWith + (headerFreeFacts mainModule) + ( moduleWith + [(noAnn, Name "x"), (noAnn, Name "y")] + [] + [Name "x", Name "y"] + ) + annotateShow optimized + importsKept optimized === [foreignQName] + + test "keeps an import read from an if branch" do + -- The single read is evaluated zero or one times per evaluation of + -- the export, so the fold declines even though the count is one. + let ext = moduleNameFromString "Ext" + optimized = + optimizedUberModule (headerFreeFacts mainModule) $ + Linker.UberModule + { uberModuleForeigns = [] + , uberModuleBindings = + [Standalone (foreignQName, theImport noAnn)] + , uberModuleExports = + [ + ( Name "main" + , ifThenElse + (refImported ext (Name "c")) + ( objectProp + (refImported mainModule Linker.foreignName) + (PropName "x") + ) + (literalInt 0) + ) + ] + } + annotateShow optimized + importsKept optimized === [foreignQName] + describe "respects @inline never on foreign export names (issue #175)" do -- The pragma annotation drained into 'moduleForeigns' must reach the -- accessor the Linker binds the name to, overriding the default diff --git a/test/Language/PureScript/Backend/Lua/Golden/Spec.hs b/test/Language/PureScript/Backend/Lua/Golden/Spec.hs index 56fd763a..f5814d74 100644 --- a/test/Language/PureScript/Backend/Lua/Golden/Spec.hs +++ b/test/Language/PureScript/Backend/Lua/Golden/Spec.hs @@ -16,7 +16,10 @@ import Language.PureScript.Backend.IR.Linker (LinkMode (..)) import Language.PureScript.Backend.IR.Linker qualified as IR import Language.PureScript.Backend.IR.Linker qualified as Linker import Language.PureScript.Backend.IR.Linter qualified as Linter -import Language.PureScript.Backend.IR.Optimizer (optimizedUberModuleChecked) +import Language.PureScript.Backend.IR.Optimizer + ( ProgramFacts (..) + , optimizedUberModuleChecked + ) import Language.PureScript.Backend.IR.Pass ( PassCheckFailure (ResultDanglingImports) ) @@ -319,16 +322,23 @@ compileCorefn outputDir uberModuleName = do -- as Backend.compileModules does, so the .ir goldens reflect the same -- pipeline. Foreign paths recorded in the CoreFn are relative to test/ps -- (the spago build dir), so resolve them from there, mirroring compileIr. - liftedModule ← liftIO $ withCurrentDir [reldir|test/ps|] do - foreignPath ← Tagged <$> makeAbsolute [reldir|foreign|] - ForeignLift.liftForeigns foreignPath uberModule - & handleForeignLiftError - & Oops.runOops + (liftedModule, factsHeaderFreeForeigns) ← + liftIO $ withCurrentDir [reldir|test/ps|] do + foreignPath ← Tagged <$> makeAbsolute [reldir|foreign|] + lifted ← + ForeignLift.liftForeigns foreignPath uberModule + & handleForeignLiftError + & Oops.runOops + -- See Note [Inlining a single-use foreign import] + (lifted,) <$> ForeignLift.headerFreeForeigns foreignPath lifted -- The checked runner lints every pass boundary (including every fixpoint -- iteration), so each golden module doubles as a scope-invariant test of -- the whole pipeline. optimized ← - either (fail . show) pure (optimizedUberModuleChecked dataDecls liftedModule) + either (fail . show) pure $ + optimizedUberModuleChecked + ProgramFacts {factsDataTypes = dataDecls, factsHeaderFreeForeigns} + liftedModule -- Golden modules are closed (real linker output), so the optimized result -- must resolve every imported reference — a dangling one compiles to a nil -- call at runtime (issue #297). Unit fixtures cannot carry this check; diff --git a/test/ps/output/Golden.ArrayOfUnits.Test/golden.ir b/test/ps/output/Golden.ArrayOfUnits.Test/golden.ir index 36aa835b..39648ca3 100644 --- a/test/ps/output/Golden.ArrayOfUnits.Test/golden.ir +++ b/test/ps/output/Golden.ArrayOfUnits.Test/golden.ir @@ -1,16 +1,13 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" - [ ( Just Never, Name "unit" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "unit" }, ObjectProp ( Just Never ) - ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" + [ ( Just Never, Name "unit" ) ] + ) ( PropName "unit" ) ), Standalone ( QName @@ -36,16 +33,13 @@ UberModule ( Ref Nothing ( Imported ( ModuleName "Effect" ) ( Name "foreign" ) ) ) ( PropName "pureE" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), RecursiveGroup ( diff --git a/test/ps/output/Golden.ArrayOfUnits.Test/golden.lua b/test/ps/output/Golden.ArrayOfUnits.Test/golden.lua index c09783df..26014b98 100644 --- a/test/ps/output/Golden.ArrayOfUnits.Test/golden.lua +++ b/test/ps/output/Golden.ArrayOfUnits.Test/golden.lua @@ -16,8 +16,7 @@ local function PSLUA_runtime_lazy(name) end end end -local Data_Unit_foreign = { unit = {} } -local Data_Unit_unit = Data_Unit_foreign.unit +local Data_Unit_unit = {} local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } local Data_Foldable_foreign = { foldrArray = function(f) @@ -48,10 +47,7 @@ local Effect_foreign = { end } local Effect_pureE = Effect_foreign.pureE -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end local Data_Foldable_foldableArray Data_Foldable_foldableArray = { foldr = Data_Foldable_foreign.foldrArray, diff --git a/test/ps/output/Golden.ArrayPatternMatch.Test/golden.ir b/test/ps/output/Golden.ArrayPatternMatch.Test/golden.ir index 1375cff2..2678f4d3 100644 --- a/test/ps/output/Golden.ArrayPatternMatch.Test/golden.ir +++ b/test/ps/output/Golden.ArrayPatternMatch.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.ArrayPatternMatch.Test/golden.lua b/test/ps/output/Golden.ArrayPatternMatch.Test/golden.lua index bb7b82dc..3d98ef38 100644 --- a/test/ps/output/Golden.ArrayPatternMatch.Test/golden.lua +++ b/test/ps/output/Golden.ArrayPatternMatch.Test/golden.lua @@ -1,10 +1,6 @@ local M = {} -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end M.Golden_ArrayPatternMatch_Test_lastOfThree = function(v) if 3 == #(v) then return v[3] else return -1 end end diff --git a/test/ps/output/Golden.BugListGenericEq.Test/golden.ir b/test/ps/output/Golden.BugListGenericEq.Test/golden.ir index 2bd886da..a1056545 100644 --- a/test/ps/output/Golden.BugListGenericEq.Test/golden.ir +++ b/test/ps/output/Golden.BugListGenericEq.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Record.Unsafe", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Record.Unsafe" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Record/Unsafe.purs" - [ ( Nothing, Name "unsafeGet" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Record.Unsafe", qnameName = Name "unsafeGet" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Record.Unsafe" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Record.Unsafe" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Record/Unsafe.purs" + [ ( Nothing, Name "unsafeGet" ) ] + ) ( PropName "unsafeGet" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), RecursiveGroup ( diff --git a/test/ps/output/Golden.BugListGenericEq.Test/golden.lua b/test/ps/output/Golden.BugListGenericEq.Test/golden.lua index 489dc786..079d52ed 100644 --- a/test/ps/output/Golden.BugListGenericEq.Test/golden.lua +++ b/test/ps/output/Golden.BugListGenericEq.Test/golden.lua @@ -1,12 +1,8 @@ local M = {} -local Record_Unsafe_foreign = { - unsafeGet = function(l) return function(r) return r[l] end end -} -local Record_Unsafe_unsafeGet = Record_Unsafe_foreign.unsafeGet -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Record_Unsafe_unsafeGet = function(l) + return function(r) return r[l] end +end +local Effect_Console_log = function(s) return function() print(s) end end local Data_HeytingAlgebra_heytingAlgebraBoolean Data_HeytingAlgebra_heytingAlgebraBoolean = { ff = false, diff --git a/test/ps/output/Golden.CSE.Test/golden.ir b/test/ps/output/Golden.CSE.Test/golden.ir index 1fbf7b0c..e6c8c3e1 100644 --- a/test/ps/output/Golden.CSE.Test/golden.ir +++ b/test/ps/output/Golden.CSE.Test/golden.ir @@ -1,12 +1,6 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Semigroup", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Semigroup" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Semigroup.purs" - [ ( Nothing, Name "concatArray" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" }, ForeignImport Nothing @@ -19,34 +13,31 @@ UberModule ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Data.Functor", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Functor" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Functor.purs" - [ ( Nothing, Name "arrayMap" ) ] - ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName { qnameModuleName = ModuleName "Golden.CSE.Test", qnameName = Name "append" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Semigroup" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Semigroup" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Semigroup.purs" + [ ( Nothing, Name "concatArray" ) ] + ) ( PropName "concatArray" ) ), Standalone ( QName { qnameModuleName = ModuleName "Golden.CSE.Test", qnameName = Name "map" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Functor" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Functor" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Functor.purs" + [ ( Nothing, Name "arrayMap" ) ] + ) ( PropName "arrayMap" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.CSE.Test/golden.lua b/test/ps/output/Golden.CSE.Test/golden.lua index f8eefdd0..0a754470 100644 --- a/test/ps/output/Golden.CSE.Test/golden.lua +++ b/test/ps/output/Golden.CSE.Test/golden.lua @@ -1,17 +1,4 @@ local M = {} -local Data_Semigroup_foreign = { - concatArray = function(xs) - return function(ys) - if #(xs) == 0 then return ys end - if #(ys) == 0 then return xs end - local result = {} - for index, value in ipairs(xs) do result[index] = value end - local offset = #(result) - for index, value in ipairs(ys) do result[index + offset] = value end - return result - end - end -} local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end, showArrayImpl = function(f) @@ -24,22 +11,26 @@ local Data_Show_foreign = { end } local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Data_Functor_foreign = { - arrayMap = function(f) - return function(arr) - local l = #(arr) - local result = {} - for i = 1, l do result[i] = f(arr[i]) end - return result - end +local Effect_Console_log = function(s) return function() print(s) end end +local Golden_CSE_Test_append = function(xs) + return function(ys) + if #(xs) == 0 then return ys end + if #(ys) == 0 then return xs end + local result = {} + for index, value in ipairs(xs) do result[index] = value end + local offset = #(result) + for index, value in ipairs(ys) do result[index + offset] = value end + return result end -} -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log -local Golden_CSE_Test_append = Data_Semigroup_foreign.concatArray -local Golden_CSE_Test_map = Data_Functor_foreign.arrayMap +end +local Golden_CSE_Test_map = function(f) + return function(arr) + local l = #(arr) + local result = {} + for i = 1, l do result[i] = f(arr[i]) end + return result + end +end local Golden_CSE_Test_logShow = function(a_S_0) return Effect_Console_log(Data_Show_foreign.showArrayImpl(Data_Show_showIntImpl)(a_S_0)) end diff --git a/test/ps/output/Golden.CharLiterals.Test/golden.ir b/test/ps/output/Golden.CharLiterals.Test/golden.ir index 698a621c..c916b9d8 100644 --- a/test/ps/output/Golden.CharLiterals.Test/golden.ir +++ b/test/ps/output/Golden.CharLiterals.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showCharImpl" ) ] - ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName { qnameModuleName = ModuleName "Golden.CharLiterals.Test", qnameName = Name "show" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showCharImpl" ) ] + ) ( PropName "showCharImpl" ) ) ], uberModuleForeigns = [], uberModuleExports = diff --git a/test/ps/output/Golden.CharLiterals.Test/golden.lua b/test/ps/output/Golden.CharLiterals.Test/golden.lua index 9e804f8f..bc882f7e 100644 --- a/test/ps/output/Golden.CharLiterals.Test/golden.lua +++ b/test/ps/output/Golden.CharLiterals.Test/golden.lua @@ -1,25 +1,19 @@ -local Data_Show_foreign = { - showCharImpl = function(n) - local code = n:byte() - if code < 32 or code == 127 then - if n == "\a" then return "'\\a'" end - if n == "\b" then return "'\\b'" end - if n == "\f" then return "'\\f'" end - if n == "\n" then return "'\\n'" end - if n == "\r" then return "'\\r'" end - if n == "\t" then return "'\\t'" end - if n == "\v" then return "'\\v'" end - return "'\\" .. tostring(code) .. "'" - end - if n == "'" or n == "\\" then return "'\\" .. n .. "'" end - return "'" .. n .. "'" +local Effect_Console_log = function(s) return function() print(s) end end +local Golden_CharLiterals_Test_show = function(n) + local code = n:byte() + if code < 32 or code == 127 then + if n == "\a" then return "'\\a'" end + if n == "\b" then return "'\\b'" end + if n == "\f" then return "'\\f'" end + if n == "\n" then return "'\\n'" end + if n == "\r" then return "'\\r'" end + if n == "\t" then return "'\\t'" end + if n == "\v" then return "'\\v'" end + return "'\\" .. tostring(code) .. "'" end -} -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log -local Golden_CharLiterals_Test_show = Data_Show_foreign.showCharImpl + if n == "'" or n == "\\" then return "'\\" .. n .. "'" end + return "'" .. n .. "'" +end return (function() local _ = Effect_Console_log(Golden_CharLiterals_Test_show("\n"))() local _ = Effect_Console_log(Golden_CharLiterals_Test_show("\t"))() diff --git a/test/ps/output/Golden.ConstantChains.Test/golden.ir b/test/ps/output/Golden.ConstantChains.Test/golden.ir index 845ea242..a91ba86f 100644 --- a/test/ps/output/Golden.ConstantChains.Test/golden.ir +++ b/test/ps/output/Golden.ConstantChains.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.ConstantChains.Test/golden.lua b/test/ps/output/Golden.ConstantChains.Test/golden.lua index 48ce551c..91049190 100644 --- a/test/ps/output/Golden.ConstantChains.Test/golden.lua +++ b/test/ps/output/Golden.ConstantChains.Test/golden.lua @@ -1,9 +1,5 @@ -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end local Golden_ConstantChains_Test_foreign = { anInt = 100, anotherInt = 7, diff --git a/test/ps/output/Golden.CprResult.Test/golden.ir b/test/ps/output/Golden.CprResult.Test/golden.ir index 2e53d412..2f2ed516 100644 --- a/test/ps/output/Golden.CprResult.Test/golden.ir +++ b/test/ps/output/Golden.CprResult.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.CprResult.Test/golden.lua b/test/ps/output/Golden.CprResult.Test/golden.lua index 2ac2d0ab..ed76729c 100644 --- a/test/ps/output/Golden.CprResult.Test/golden.lua +++ b/test/ps/output/Golden.CprResult.Test/golden.lua @@ -1,10 +1,6 @@ local M = {} -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end local Golden_CprResult_Test_sub_S_w = function(x_S_0, y_S_0) return x_S_0 - y_S_0 end diff --git a/test/ps/output/Golden.CprState.Test/golden.ir b/test/ps/output/Golden.CprState.Test/golden.ir index 1c25759f..2ac6979a 100644 --- a/test/ps/output/Golden.CprState.Test/golden.ir +++ b/test/ps/output/Golden.CprState.Test/golden.ir @@ -1,30 +1,15 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" - [ ( Just Never, Name "unit" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "unit" }, ObjectProp ( Just Never ) - ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" + [ ( Just Never, Name "unit" ) ] + ) ( PropName "unit" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Identity", qnameName = Name "applyIdentity" }, LiteralObject Nothing @@ -1029,12 +1014,18 @@ UberModule ( Name "go", Ref Nothing ( Imported ( ModuleName "Golden.CprState.Test" ) ( Name "go" ) ) ), ( Name "main", AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ) ( DataArgumentByIndex Nothing ProductType 0 diff --git a/test/ps/output/Golden.CprState.Test/golden.lua b/test/ps/output/Golden.CprState.Test/golden.lua index 8fea6229..013c7dfd 100644 --- a/test/ps/output/Golden.CprState.Test/golden.lua +++ b/test/ps/output/Golden.CprState.Test/golden.lua @@ -1,9 +1,4 @@ -local Data_Unit_foreign = { unit = {} } -local Data_Unit_unit = Data_Unit_foreign.unit -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} +local Data_Unit_unit = {} local Data_Identity_applyIdentity = { apply = function(v) return function(v1) return v(v1) end end, Functor0 = function() @@ -160,4 +155,6 @@ local Golden_CprState_Test_go = Golden_CprState_Test_bindStateT.bind(Golden_CprS end) end) end) -return Effect_Console_foreign.log(Data_Show_foreign.showIntImpl((Golden_CprState_Test_go(0))[1]))() +return (function(s) return function() print(s) end end)((function(n) + return tostring(n) +end)((Golden_CprState_Test_go(0))[1]))() diff --git a/test/ps/output/Golden.DerivedFunctor.Test/golden.ir b/test/ps/output/Golden.DerivedFunctor.Test/golden.ir index 9bc585da..9f88c27a 100644 --- a/test/ps/output/Golden.DerivedFunctor.Test/golden.ir +++ b/test/ps/output/Golden.DerivedFunctor.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.DerivedFunctor.Test/golden.lua b/test/ps/output/Golden.DerivedFunctor.Test/golden.lua index e2ca9e49..a2e9f943 100644 --- a/test/ps/output/Golden.DerivedFunctor.Test/golden.lua +++ b/test/ps/output/Golden.DerivedFunctor.Test/golden.lua @@ -1,10 +1,6 @@ local M = {} -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end local Golden_DerivedFunctor_Test_Leaf = { "Golden.DerivedFunctor.Test∷Tree.Leaf" } diff --git a/test/ps/output/Golden.DirectiveAccessor.Test/golden.ir b/test/ps/output/Golden.DirectiveAccessor.Test/golden.ir index f9352433..e13c9c0e 100644 --- a/test/ps/output/Golden.DirectiveAccessor.Test/golden.ir +++ b/test/ps/output/Golden.DirectiveAccessor.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.DirectiveAccessor.Test/golden.lua b/test/ps/output/Golden.DirectiveAccessor.Test/golden.lua index cffddde7..f4c2fd40 100644 --- a/test/ps/output/Golden.DirectiveAccessor.Test/golden.lua +++ b/test/ps/output/Golden.DirectiveAccessor.Test/golden.lua @@ -1,9 +1,5 @@ -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end local Golden_DirectiveAccessor_Test_ops = { add = function(a) return function(b) return a + b end end, mul = function(a0) return function(b0) return a0 * b0 end end diff --git a/test/ps/output/Golden.DirectiveArity.Test/golden.ir b/test/ps/output/Golden.DirectiveArity.Test/golden.ir index 6c2ce39c..6f10c478 100644 --- a/test/ps/output/Golden.DirectiveArity.Test/golden.ir +++ b/test/ps/output/Golden.DirectiveArity.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.DirectiveArity.Test/golden.lua b/test/ps/output/Golden.DirectiveArity.Test/golden.lua index b25ca524..23e46657 100644 --- a/test/ps/output/Golden.DirectiveArity.Test/golden.lua +++ b/test/ps/output/Golden.DirectiveArity.Test/golden.lua @@ -1,10 +1,6 @@ local M = {} -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end M.Golden_DirectiveArity_Test_Op = function(value0) return { value0 } end M.Golden_DirectiveArity_Test_runOp = function(op) return function(x) return op[1](x) end diff --git a/test/ps/output/Golden.DirectiveDerived.Test/golden.ir b/test/ps/output/Golden.DirectiveDerived.Test/golden.ir index a1a3756b..455a243d 100644 --- a/test/ps/output/Golden.DirectiveDerived.Test/golden.ir +++ b/test/ps/output/Golden.DirectiveDerived.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.DirectiveDerived.Test/golden.lua b/test/ps/output/Golden.DirectiveDerived.Test/golden.lua index 56851ee5..3c9c24c7 100644 --- a/test/ps/output/Golden.DirectiveDerived.Test/golden.lua +++ b/test/ps/output/Golden.DirectiveDerived.Test/golden.lua @@ -1,9 +1,5 @@ -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end local Golden_DirectiveDerived_Test_combine = function(a) return function(b) return function(c) diff --git a/test/ps/output/Golden.DirectivePack.Test/golden.ir b/test/ps/output/Golden.DirectivePack.Test/golden.ir index f229fda7..1a8df455 100644 --- a/test/ps/output/Golden.DirectivePack.Test/golden.ir +++ b/test/ps/output/Golden.DirectivePack.Test/golden.ir @@ -1,16 +1,13 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" - [ ( Just Never, Name "unit" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "unit" }, ObjectProp ( Just Never ) - ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" + [ ( Just Never, Name "unit" ) ] + ) ( PropName "unit" ) ), Standalone ( QName @@ -19,16 +16,13 @@ UberModule ( ModuleName "Data.Semigroup" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Semigroup.purs" [ ( Nothing, Name "concatArray" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone ( QName @@ -61,16 +55,13 @@ UberModule ( ModuleName "Effect" ) ".spago/p/effect/82bac3dff904fa34534c4f5b9deeb5da359471c8/src/Effect.purs" [ ( Nothing, Name "pureE" ), ( Nothing, Name "bindE" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.DirectivePack.Test/golden.lua b/test/ps/output/Golden.DirectivePack.Test/golden.lua index 7396e18e..703bc6f3 100644 --- a/test/ps/output/Golden.DirectivePack.Test/golden.lua +++ b/test/ps/output/Golden.DirectivePack.Test/golden.lua @@ -17,8 +17,7 @@ local function PSLUA_runtime_lazy(name) end end local M = {} -local Data_Unit_foreign = { unit = {} } -local Data_Unit_unit = Data_Unit_foreign.unit +local Data_Unit_unit = {} local Data_Semigroup_foreign = { concatArray = function(xs) return function(ys) @@ -32,8 +31,7 @@ local Data_Semigroup_foreign = { end end } -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl +local Data_Show_showIntImpl = function(n) return tostring(n) end local Data_EuclideanRing_foreign = { -- math.maxinteger is Lua 5.3+; PureScript Int is 32-bit, hence the -- literal bound in intDegree. @@ -65,10 +63,7 @@ local Effect_foreign = { return function(f) return function() return f(a())() end end end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end local Effect_Ref_foreign = { _new = function(val) return function() return { value = val } end end, read = function(ref) return function() return ref.value end end, diff --git a/test/ps/output/Golden.DistributeIntoIf.Test/golden.ir b/test/ps/output/Golden.DistributeIntoIf.Test/golden.ir index a0eb18dc..8214d949 100644 --- a/test/ps/output/Golden.DistributeIntoIf.Test/golden.ir +++ b/test/ps/output/Golden.DistributeIntoIf.Test/golden.ir @@ -1,41 +1,30 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Golden.DistributeIntoIf.Test", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Golden.DistributeIntoIf.Test" ) "src/Golden/DistributeIntoIf/Test.purs" - [ ( Nothing, Name "flag" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Golden.DistributeIntoIf.Test", qnameName = Name "flag" }, ObjectProp Nothing - ( Ref Nothing - ( Imported ( ModuleName "Golden.DistributeIntoIf.Test" ) ( Name "foreign" ) ) + ( ForeignImport Nothing + ( ModuleName "Golden.DistributeIntoIf.Test" ) "src/Golden/DistributeIntoIf/Test.purs" + [ ( Nothing, Name "flag" ) ] ) ( PropName "flag" ) ), RecursiveGroup diff --git a/test/ps/output/Golden.DistributeIntoIf.Test/golden.lua b/test/ps/output/Golden.DistributeIntoIf.Test/golden.lua index e6d7a67d..9c102320 100644 --- a/test/ps/output/Golden.DistributeIntoIf.Test/golden.lua +++ b/test/ps/output/Golden.DistributeIntoIf.Test/golden.lua @@ -1,11 +1,6 @@ -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log -local Golden_DistributeIntoIf_Test_foreign = { flag = true } -local Golden_DistributeIntoIf_Test_flag = Golden_DistributeIntoIf_Test_foreign.flag +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end +local Golden_DistributeIntoIf_Test_flag = true local Data_HeytingAlgebra_heytingAlgebraBoolean Data_HeytingAlgebra_heytingAlgebraBoolean = { ff = false, diff --git a/test/ps/output/Golden.EffectPureChain.Test/golden.ir b/test/ps/output/Golden.EffectPureChain.Test/golden.ir index 284f8d85..a3206227 100644 --- a/test/ps/output/Golden.EffectPureChain.Test/golden.ir +++ b/test/ps/output/Golden.EffectPureChain.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.EffectPureChain.Test/golden.lua b/test/ps/output/Golden.EffectPureChain.Test/golden.lua index 57cd2566..5f640649 100644 --- a/test/ps/output/Golden.EffectPureChain.Test/golden.lua +++ b/test/ps/output/Golden.EffectPureChain.Test/golden.lua @@ -1,10 +1,6 @@ local M = {} -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end local Data_Show_showInt = { show = Data_Show_showIntImpl } local Data_Show_show = function(dict) return dict.show end local Golden_EffectPureChain_Test_show = Data_Show_showIntImpl diff --git a/test/ps/output/Golden.Fibonacci.Test/golden.ir b/test/ps/output/Golden.Fibonacci.Test/golden.ir index eae02427..9fc092e9 100644 --- a/test/ps/output/Golden.Fibonacci.Test/golden.ir +++ b/test/ps/output/Golden.Fibonacci.Test/golden.ir @@ -1,18 +1,6 @@ UberModule { uberModuleBindings = - [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), RecursiveGroup + [ RecursiveGroup ( ( QName { qnameModuleName = ModuleName "Golden.Fibonacci.Test", qnameName = Name "fib" @@ -55,12 +43,18 @@ UberModule ), ( Name "main", AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ) ( AppN Nothing diff --git a/test/ps/output/Golden.Fibonacci.Test/golden.lua b/test/ps/output/Golden.Fibonacci.Test/golden.lua index cbdd9ff6..cbd2cf7f 100644 --- a/test/ps/output/Golden.Fibonacci.Test/golden.lua +++ b/test/ps/output/Golden.Fibonacci.Test/golden.lua @@ -1,7 +1,3 @@ -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} local Golden_Fibonacci_Test_fib Golden_Fibonacci_Test_fib = function(v) if 0 == v then @@ -12,4 +8,6 @@ Golden_Fibonacci_Test_fib = function(v) return Golden_Fibonacci_Test_fib(v - 1) + Golden_Fibonacci_Test_fib(v - 2) end end -return Effect_Console_foreign.log(Data_Show_foreign.showIntImpl(Golden_Fibonacci_Test_fib(32)))() +return (function(s) return function() print(s) end end)((function(n) + return tostring(n) +end)(Golden_Fibonacci_Test_fib(32)))() diff --git a/test/ps/output/Golden.FloatIn.Test/golden.ir b/test/ps/output/Golden.FloatIn.Test/golden.ir index a5c9ac88..e9b6662c 100644 --- a/test/ps/output/Golden.FloatIn.Test/golden.ir +++ b/test/ps/output/Golden.FloatIn.Test/golden.ir @@ -1,52 +1,40 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" - [ ( Just Never, Name "unit" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "unit" }, ObjectProp ( Just Never ) - ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" + [ ( Just Never, Name "unit" ) ] + ) ( PropName "unit" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Golden.FloatIn.Test", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Golden.FloatIn.Test" ) "src/Golden/FloatIn/Test.purs" - [ ( Nothing, Name "tick" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Golden.FloatIn.Test", qnameName = Name "tick" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Golden.FloatIn.Test" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Golden.FloatIn.Test" ) "src/Golden/FloatIn/Test.purs" + [ ( Nothing, Name "tick" ) ] + ) ( PropName "tick" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.FloatIn.Test/golden.lua b/test/ps/output/Golden.FloatIn.Test/golden.lua index 03ff58ee..69ea5596 100644 --- a/test/ps/output/Golden.FloatIn.Test/golden.lua +++ b/test/ps/output/Golden.FloatIn.Test/golden.lua @@ -1,16 +1,8 @@ local M = {} -local Data_Unit_foreign = { unit = {} } -local Data_Unit_unit = Data_Unit_foreign.unit -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log -local Golden_FloatIn_Test_foreign = { - tick = function(n) print("tick") return n + n end -} -local Golden_FloatIn_Test_tick = Golden_FloatIn_Test_foreign.tick +local Data_Unit_unit = {} +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end +local Golden_FloatIn_Test_tick = function(n) print("tick") return n + n end M.Golden_FloatIn_Test_expensive = function(x) return x * x + 1 end return (function() local _ = Effect_Console_log(Data_Show_showIntImpl(20))() diff --git a/test/ps/output/Golden.Foreign.Test/golden.ir b/test/ps/output/Golden.Foreign.Test/golden.ir index 3a0652d8..2f7718e6 100644 --- a/test/ps/output/Golden.Foreign.Test/golden.ir +++ b/test/ps/output/Golden.Foreign.Test/golden.ir @@ -1,12 +1,6 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Golden.Foreign.Lib", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Golden.Foreign.Lib" ) "src/Golden/Foreign/Lib.purs" - [ ( Nothing, Name "alive" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Golden.Foreign.Test", qnameName = Name "foreign" }, ForeignImport Nothing @@ -23,7 +17,10 @@ UberModule [ ObjectProp Nothing ( Ref Nothing ( Imported ( ModuleName "Golden.Foreign.Test" ) ( Name "foreign" ) ) ) ( PropName "boo" ), ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Golden.Foreign.Lib" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Golden.Foreign.Lib" ) "src/Golden/Foreign/Lib.purs" + [ ( Nothing, Name "alive" ) ] + ) ( PropName "alive" ) ] ) diff --git a/test/ps/output/Golden.Foreign.Test/golden.lua b/test/ps/output/Golden.Foreign.Test/golden.lua index 9f897ce5..a3f5d872 100644 --- a/test/ps/output/Golden.Foreign.Test/golden.lua +++ b/test/ps/output/Golden.Foreign.Test/golden.lua @@ -1,12 +1,8 @@ -local Golden_Foreign_Lib_foreign = { alive = 100 } local Golden_Foreign_Test_foreign = (function() local fooBar = 42 return { foo = fooBar + 1, boo = fooBar + 2 } end)() return { foo = Golden_Foreign_Test_foreign.foo, - baz = { - [1] = Golden_Foreign_Test_foreign.boo, - [2] = Golden_Foreign_Lib_foreign.alive - } + baz = { [1] = Golden_Foreign_Test_foreign.boo, [2] = 100 } } diff --git a/test/ps/output/Golden.ForeignAccessorDefault.Test/golden.ir b/test/ps/output/Golden.ForeignAccessorDefault.Test/golden.ir index f23752db..45971d34 100644 --- a/test/ps/output/Golden.ForeignAccessorDefault.Test/golden.ir +++ b/test/ps/output/Golden.ForeignAccessorDefault.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.ForeignAccessorDefault.Test/golden.lua b/test/ps/output/Golden.ForeignAccessorDefault.Test/golden.lua index 573ed5e9..ae89d6c8 100644 --- a/test/ps/output/Golden.ForeignAccessorDefault.Test/golden.lua +++ b/test/ps/output/Golden.ForeignAccessorDefault.Test/golden.lua @@ -1,9 +1,5 @@ -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end local Golden_ForeignAccessorDefault_Test_foreign = { double = function(n) return n * 2 end, bump = function(n) return n + 1 end diff --git a/test/ps/output/Golden.ForeignHeader.Test/corefn.json b/test/ps/output/Golden.ForeignHeader.Test/corefn.json new file mode 100644 index 00000000..fb8e6859 --- /dev/null +++ b/test/ps/output/Golden.ForeignHeader.Test/corefn.json @@ -0,0 +1 @@ +{"builtWith":"0.15.16","comments":[{"LineComment":" | Pins the header condition of the single-use foreign-import fold"},{"LineComment":" | (#251). The import is read exactly once, from the right-hand side of"},{"LineComment":" | the shared accessor `tag` — a once-evaluated position — so only the"},{"LineComment":" | header statement in `Test.lua` holds the table hoisted: its effects"},{"LineComment":" | run at a fixed point in module init, and folding the import into the"},{"LineComment":" | accessor would move them."},{"LineComment":" |"},{"LineComment":" | `Golden.ForeignAccessorDefault.Test` is the same shape over"},{"LineComment":" | header-free sources, where the pair does collapse."}],"decls":[{"annotation":{"meta":null,"sourceSpan":{"end":[19,20],"start":[19,1]}},"bindType":"NonRec","expression":{"abstraction":{"abstraction":{"abstraction":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[21,10],"start":[21,3]}},"type":"Var","value":{"identifier":"discard","moduleName":["Control","Bind"]}},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[21,10],"start":[21,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"discardUnit","moduleName":["Control","Bind"]}},"type":"App"},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[21,10],"start":[21,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"bindEffect","moduleName":["Effect"]}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[21,10],"start":[21,3]}},"argument":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[21,6],"start":[21,3]}},"type":"Var","value":{"identifier":"log","moduleName":["Effect","Console"]}},"annotation":{"meta":null,"sourceSpan":{"end":[21,10],"start":[21,3]}},"argument":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[21,10],"start":[21,7]}},"type":"Var","value":{"identifier":"tag","moduleName":["Golden","ForeignHeader","Test"]}},"type":"App"},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[21,10],"start":[21,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[21,10],"start":[21,3]}},"argument":"$__unused","body":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[22,6],"start":[22,3]}},"type":"Var","value":{"identifier":"log","moduleName":["Effect","Console"]}},"annotation":{"meta":null,"sourceSpan":{"end":[22,10],"start":[22,3]}},"argument":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[22,10],"start":[22,7]}},"type":"Var","value":{"identifier":"tag","moduleName":["Golden","ForeignHeader","Test"]}},"type":"App"},"type":"Abs"},"type":"App"},"identifier":"main"}],"exports":["tag","main"],"foreign":["tag"],"imports":[{"annotation":{"meta":null,"sourceSpan":{"end":[22,10],"start":[10,1]}},"moduleName":["Control","Bind"]},{"annotation":{"meta":null,"sourceSpan":{"end":[22,10],"start":[10,1]}},"moduleName":["Effect"]},{"annotation":{"meta":null,"sourceSpan":{"end":[22,10],"start":[10,1]}},"moduleName":["Effect","Console"]},{"annotation":{"meta":null,"sourceSpan":{"end":[22,10],"start":[10,1]}},"moduleName":["Golden","ForeignHeader","Test"]},{"annotation":{"meta":null,"sourceSpan":{"end":[12,15],"start":[12,1]}},"moduleName":["Prelude"]},{"annotation":{"meta":null,"sourceSpan":{"end":[22,10],"start":[10,1]}},"moduleName":["Prim"]}],"moduleName":["Golden","ForeignHeader","Test"],"modulePath":"src/Golden/ForeignHeader/Test.purs","reExports":{},"sourceSpan":{"end":[22,10],"start":[10,1]}} \ No newline at end of file diff --git a/test/ps/output/Golden.ForeignHeader.Test/eval/.gitignore b/test/ps/output/Golden.ForeignHeader.Test/eval/.gitignore new file mode 100644 index 00000000..d2dc29bb --- /dev/null +++ b/test/ps/output/Golden.ForeignHeader.Test/eval/.gitignore @@ -0,0 +1 @@ +actual.txt diff --git a/test/ps/output/Golden.ForeignHeader.Test/eval/golden.txt b/test/ps/output/Golden.ForeignHeader.Test/eval/golden.txt new file mode 100644 index 00000000..f0ada7ab --- /dev/null +++ b/test/ps/output/Golden.ForeignHeader.Test/eval/golden.txt @@ -0,0 +1,2 @@ +tagged +tagged diff --git a/test/ps/output/Golden.ForeignHeader.Test/golden.ir b/test/ps/output/Golden.ForeignHeader.Test/golden.ir new file mode 100644 index 00000000..754fe741 --- /dev/null +++ b/test/ps/output/Golden.ForeignHeader.Test/golden.ir @@ -0,0 +1,56 @@ +UberModule + { uberModuleBindings = + [ Standalone + ( QName + { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" + }, ObjectProp Nothing + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) + ( PropName "log" ) + ), Standalone + ( QName + { qnameModuleName = ModuleName "Golden.ForeignHeader.Test", qnameName = Name "foreign" + }, ForeignImport Nothing + ( ModuleName "Golden.ForeignHeader.Test" ) "src/Golden/ForeignHeader/Test.purs" + [ ( Nothing, Name "tag" ) ] + ), Standalone + ( QName + { qnameModuleName = ModuleName "Golden.ForeignHeader.Test", qnameName = Name "tag" + }, ObjectProp Nothing + ( Ref Nothing ( Imported ( ModuleName "Golden.ForeignHeader.Test" ) ( Name "foreign" ) ) ) + ( PropName "tag" ) + ) + ], uberModuleForeigns = [], uberModuleExports = + [ + ( Name "tag", Ref Nothing + ( Imported ( ModuleName "Golden.ForeignHeader.Test" ) ( Name "tag" ) ) + ), + ( Name "main", AbsN Nothing + ( ParamUnused Nothing :| [] ) + ( Let Nothing + ( Standalone + ( Nothing, Name "_", AppN Nothing + ( AppN Nothing + ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "log" ) ) ) + ( Ref Nothing + ( Imported ( ModuleName "Golden.ForeignHeader.Test" ) ( Name "tag" ) ) :| [] + ) + ) + ( Ref Nothing ( Imported ( ModuleName "Prim" ) ( Name "$magicDoRun" ) ) :| [] ) + ) :| [] + ) + ( AppN Nothing + ( AppN Nothing + ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "log" ) ) ) + ( Ref Nothing + ( Imported ( ModuleName "Golden.ForeignHeader.Test" ) ( Name "tag" ) ) :| [] + ) + ) + ( Ref Nothing ( Imported ( ModuleName "Prim" ) ( Name "$magicDoRun" ) ) :| [] ) + ) + ) + ) + ] + } \ No newline at end of file diff --git a/test/ps/output/Golden.ForeignHeader.Test/golden.lua b/test/ps/output/Golden.ForeignHeader.Test/golden.lua new file mode 100644 index 00000000..f49e9793 --- /dev/null +++ b/test/ps/output/Golden.ForeignHeader.Test/golden.lua @@ -0,0 +1,10 @@ +local Effect_Console_log = function(s) return function() print(s) end end +local Golden_ForeignHeader_Test_foreign = (function() + local prefix = "tag" + return { tag = prefix .. "ged" } +end)() +local Golden_ForeignHeader_Test_tag = Golden_ForeignHeader_Test_foreign.tag +return (function() + local _ = Effect_Console_log(Golden_ForeignHeader_Test_tag)() + return Effect_Console_log(Golden_ForeignHeader_Test_tag)() +end)() diff --git a/test/ps/output/Golden.ForeignSharing.Test/golden.ir b/test/ps/output/Golden.ForeignSharing.Test/golden.ir index 8021c27d..5943de33 100644 --- a/test/ps/output/Golden.ForeignSharing.Test/golden.ir +++ b/test/ps/output/Golden.ForeignSharing.Test/golden.ir @@ -1,45 +1,32 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone - ( QName - { qnameModuleName = ModuleName "Golden.ForeignSharing.Token", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Golden.ForeignSharing.Token" ) "src/Golden/ForeignSharing/Token.purs" - [ ( Nothing, Name "token" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Golden.ForeignSharing.Token", qnameName = Name "token" }, ObjectProp Nothing - ( Ref Nothing - ( Imported ( ModuleName "Golden.ForeignSharing.Token" ) ( Name "foreign" ) ) + ( ForeignImport Nothing + ( ModuleName "Golden.ForeignSharing.Token" ) "src/Golden/ForeignSharing/Token.purs" + [ ( Nothing, Name "token" ) ] ) ( PropName "token" ) - ), Standalone - ( QName - { qnameModuleName = ModuleName "Golden.ForeignSharing.Test", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Golden.ForeignSharing.Test" ) "src/Golden/ForeignSharing/Test.purs" - [ ( Nothing, Name "same" ) ] ) ], uberModuleForeigns = [], uberModuleExports = [ ( Name "main", AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( IfThenElse Nothing ( AppN Nothing ( AppN Nothing ( ObjectProp Nothing - ( Ref Nothing - ( Imported ( ModuleName "Golden.ForeignSharing.Test" ) ( Name "foreign" ) ) + ( ForeignImport Nothing + ( ModuleName "Golden.ForeignSharing.Test" ) "src/Golden/ForeignSharing/Test.purs" + [ ( Nothing, Name "same" ) ] ) ( PropName "same" ) ) diff --git a/test/ps/output/Golden.ForeignSharing.Test/golden.lua b/test/ps/output/Golden.ForeignSharing.Test/golden.lua index 943c913e..2ebf5ff8 100644 --- a/test/ps/output/Golden.ForeignSharing.Test/golden.lua +++ b/test/ps/output/Golden.ForeignSharing.Test/golden.lua @@ -1,13 +1,8 @@ -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Golden_ForeignSharing_Token_foreign = { token = {} } -local Golden_ForeignSharing_Token_token = Golden_ForeignSharing_Token_foreign.token -local Golden_ForeignSharing_Test_foreign = { - same = function(a) return function(b) return rawequal(a, b) end end -} -return Effect_Console_foreign.log((function() - if Golden_ForeignSharing_Test_foreign.same(Golden_ForeignSharing_Token_token)(Golden_ForeignSharing_Token_token) then +local Golden_ForeignSharing_Token_token = {} +return (function(s) return function() print(s) end end)((function() + if (function(a) + return function(b) return rawequal(a, b) end + end)(Golden_ForeignSharing_Token_token)(Golden_ForeignSharing_Token_token) then return "shared" else return "fresh" diff --git a/test/ps/output/Golden.ForeignSharing.Token/golden.ir b/test/ps/output/Golden.ForeignSharing.Token/golden.ir index fe91ac1c..aa011832 100644 --- a/test/ps/output/Golden.ForeignSharing.Token/golden.ir +++ b/test/ps/output/Golden.ForeignSharing.Token/golden.ir @@ -1,17 +1,10 @@ UberModule - { uberModuleBindings = - [ Standalone - ( QName - { qnameModuleName = ModuleName "Golden.ForeignSharing.Token", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Golden.ForeignSharing.Token" ) "src/Golden/ForeignSharing/Token.purs" - [ ( Nothing, Name "token" ) ] - ) - ], uberModuleForeigns = [], uberModuleExports = + { uberModuleBindings = [], uberModuleForeigns = [], uberModuleExports = [ ( Name "token", ObjectProp Nothing - ( Ref Nothing - ( Imported ( ModuleName "Golden.ForeignSharing.Token" ) ( Name "foreign" ) ) + ( ForeignImport Nothing + ( ModuleName "Golden.ForeignSharing.Token" ) "src/Golden/ForeignSharing/Token.purs" + [ ( Nothing, Name "token" ) ] ) ( PropName "token" ) ) diff --git a/test/ps/output/Golden.ForeignSharing.Token/golden.lua b/test/ps/output/Golden.ForeignSharing.Token/golden.lua index 38e22c70..c38067a1 100644 --- a/test/ps/output/Golden.ForeignSharing.Token/golden.lua +++ b/test/ps/output/Golden.ForeignSharing.Token/golden.lua @@ -1,2 +1 @@ -local Golden_ForeignSharing_Token_foreign = { token = {} } -return { token = Golden_ForeignSharing_Token_foreign.token } +return { token = {} } diff --git a/test/ps/output/Golden.GenericEqTwoTypes.Test/golden.ir b/test/ps/output/Golden.GenericEqTwoTypes.Test/golden.ir index e8ee0e4d..0be9ed8b 100644 --- a/test/ps/output/Golden.GenericEqTwoTypes.Test/golden.ir +++ b/test/ps/output/Golden.GenericEqTwoTypes.Test/golden.ir @@ -7,16 +7,13 @@ UberModule ( ModuleName "Record.Unsafe" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Record/Unsafe.purs" [ ( Nothing, Name "unsafeGet" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.GenericEqTwoTypes.Test/golden.lua b/test/ps/output/Golden.GenericEqTwoTypes.Test/golden.lua index fcb1ae00..f99dbd42 100644 --- a/test/ps/output/Golden.GenericEqTwoTypes.Test/golden.lua +++ b/test/ps/output/Golden.GenericEqTwoTypes.Test/golden.lua @@ -2,10 +2,7 @@ local M = {} local Record_Unsafe_foreign = { unsafeGet = function(l) return function(r) return r[l] end end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end local Type_Proxy_Proxy = {} local Data_HeytingAlgebra_heytingAlgebraBoolean Data_HeytingAlgebra_heytingAlgebraBoolean = { diff --git a/test/ps/output/Golden.HelloPrelude.Test/golden.ir b/test/ps/output/Golden.HelloPrelude.Test/golden.ir index eea95651..deb1bda5 100644 --- a/test/ps/output/Golden.HelloPrelude.Test/golden.ir +++ b/test/ps/output/Golden.HelloPrelude.Test/golden.ir @@ -1,29 +1,23 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" - [ ( Just Never, Name "unit" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "unit" }, ObjectProp ( Just Never ) - ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" + [ ( Just Never, Name "unit" ) ] + ) ( PropName "unit" ) - ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect" ) ".spago/p/effect/82bac3dff904fa34534c4f5b9deeb5da359471c8/src/Effect.purs" - [ ( Nothing, Name "pureE" ) ] ) ], uberModuleForeigns = [], uberModuleExports = [ ( Name "main", AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect" ) ".spago/p/effect/82bac3dff904fa34534c4f5b9deeb5da359471c8/src/Effect.purs" + [ ( Nothing, Name "pureE" ) ] + ) ( PropName "pureE" ) ) ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "unit" ) ) :| [] ) diff --git a/test/ps/output/Golden.HelloPrelude.Test/golden.lua b/test/ps/output/Golden.HelloPrelude.Test/golden.lua index 822cc6be..1cb07fe5 100644 --- a/test/ps/output/Golden.HelloPrelude.Test/golden.lua +++ b/test/ps/output/Golden.HelloPrelude.Test/golden.lua @@ -1,6 +1,4 @@ -local Data_Unit_foreign = { unit = {} } -local Data_Unit_unit = Data_Unit_foreign.unit -local Effect_foreign = { - pureE = function(a) return function() return a end end +local Data_Unit_unit = {} +return { + main = (function(a) return function() return a end end)(Data_Unit_unit) } -return { main = Effect_foreign.pureE(Data_Unit_unit) } diff --git a/test/ps/output/Golden.Issue37.Test/golden.ir b/test/ps/output/Golden.Issue37.Test/golden.ir index a1da8e60..cc924a1b 100644 --- a/test/ps/output/Golden.Issue37.Test/golden.ir +++ b/test/ps/output/Golden.Issue37.Test/golden.ir @@ -1,16 +1,13 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" - [ ( Just Never, Name "unit" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "unit" }, ObjectProp ( Just Never ) - ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" + [ ( Just Never, Name "unit" ) ] + ) ( PropName "unit" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.Issue37.Test/golden.lua b/test/ps/output/Golden.Issue37.Test/golden.lua index 5db3e684..f2b45442 100644 --- a/test/ps/output/Golden.Issue37.Test/golden.lua +++ b/test/ps/output/Golden.Issue37.Test/golden.lua @@ -16,8 +16,7 @@ local function PSLUA_runtime_lazy(name) end end end -local Data_Unit_foreign = { unit = {} } -local Data_Unit_unit = Data_Unit_foreign.unit +local Data_Unit_unit = {} local Effect_foreign = { pureE = function(a) return function() return a end end, bindE = function(a) diff --git a/test/ps/output/Golden.JoinPoints.Test/golden.ir b/test/ps/output/Golden.JoinPoints.Test/golden.ir index 96965a60..edf703bc 100644 --- a/test/ps/output/Golden.JoinPoints.Test/golden.ir +++ b/test/ps/output/Golden.JoinPoints.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.JoinPoints.Test/golden.lua b/test/ps/output/Golden.JoinPoints.Test/golden.lua index 2ae9385f..960714bb 100644 --- a/test/ps/output/Golden.JoinPoints.Test/golden.lua +++ b/test/ps/output/Golden.JoinPoints.Test/golden.lua @@ -1,9 +1,5 @@ -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end local Golden_JoinPoints_Test_logShow = function(a_S_0) return Effect_Console_log(Data_Show_showIntImpl(a_S_0)) end diff --git a/test/ps/output/Golden.LengthLift.Test/golden.ir b/test/ps/output/Golden.LengthLift.Test/golden.ir index c1d8b5eb..52d2d3a9 100644 --- a/test/ps/output/Golden.LengthLift.Test/golden.ir +++ b/test/ps/output/Golden.LengthLift.Test/golden.ir @@ -13,12 +13,6 @@ UberModule ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Control.Monad.ST.Internal", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Control.Monad.ST.Internal" ) ".spago/p/st/6d41fd264a05b9a089e79322b22b906597ea7c36/src/Control/Monad/ST/Internal.purs" - [ ( Nothing, Name "pure_" ), ( Nothing, Name "bind_" ), ( Nothing, Name "run" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Array.ST", qnameName = Name "foreign" }, ForeignImport Nothing @@ -35,16 +29,13 @@ UberModule ( Ref Nothing ( Imported ( ModuleName "Data.Array.ST" ) ( Name "foreign" ) ) ) ( PropName "lengthImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName @@ -57,8 +48,9 @@ UberModule { qnameModuleName = ModuleName "Golden.LengthLift.Test", qnameName = Name "lengthsAroundPush" }, AppN Nothing ( ObjectProp Nothing - ( Ref Nothing - ( Imported ( ModuleName "Control.Monad.ST.Internal" ) ( Name "foreign" ) ) + ( ForeignImport Nothing + ( ModuleName "Control.Monad.ST.Internal" ) ".spago/p/st/6d41fd264a05b9a089e79322b22b906597ea7c36/src/Control/Monad/ST/Internal.purs" + [ ( Nothing, Name "pure_" ), ( Nothing, Name "bind_" ), ( Nothing, Name "run" ) ] ) ( PropName "run" ) ) diff --git a/test/ps/output/Golden.LengthLift.Test/golden.lua b/test/ps/output/Golden.LengthLift.Test/golden.lua index fd1128b6..a4b7ab6c 100644 --- a/test/ps/output/Golden.LengthLift.Test/golden.lua +++ b/test/ps/output/Golden.LengthLift.Test/golden.lua @@ -11,13 +11,6 @@ local Data_Show_foreign = { end } local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Control_Monad_ST_Internal_foreign = { - pure_ = function(a) return function() return a end end, - bind_ = function(a) - return function(f) return function() return f(a())() end end - end, - run = function(f) return f() end -} local Data_Array_ST_foreign = (function() -- Lua 5.1 has no table.move, so provide an overlap-safe equivalent with the -- same semantics as Lua 5.3's table.move(a1, f, e, t, a2): copy a1[f..e] to @@ -42,12 +35,11 @@ local Data_Array_ST_foreign = (function() } end)() local Data_Array_ST_lengthImpl = Data_Array_ST_foreign.lengthImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end M.Golden_LengthLift_Test_widthOf = function(s_S_0) return #(s_S_0) end -local Golden_LengthLift_Test_lengthsAroundPush = Control_Monad_ST_Internal_foreign.run(function( ) +local Golden_LengthLift_Test_lengthsAroundPush = (function(f) + return f() +end)(function() local arr = Data_Array_ST_foreign.thawImpl({ [1] = 1, [2] = 2, [3] = 3 }) local before = Data_Array_ST_lengthImpl(arr) local _ = Data_Array_ST_foreign.pushImpl(4, arr) diff --git a/test/ps/output/Golden.LongApplyChain.Test/golden.ir b/test/ps/output/Golden.LongApplyChain.Test/golden.ir index bd11ddec..27613d42 100644 --- a/test/ps/output/Golden.LongApplyChain.Test/golden.ir +++ b/test/ps/output/Golden.LongApplyChain.Test/golden.ir @@ -7,12 +7,6 @@ UberModule ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" [ ( Nothing, Name "showIntImpl" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Golden.LongApplyChain.Test", qnameName = Name "compute" }, Ctor Nothing SumType @@ -28,7 +22,10 @@ UberModule ), ( Name "main", AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( IfThenElse Nothing diff --git a/test/ps/output/Golden.LongApplyChain.Test/golden.lua b/test/ps/output/Golden.LongApplyChain.Test/golden.lua index 436318eb..2a5d3bd4 100644 --- a/test/ps/output/Golden.LongApplyChain.Test/golden.lua +++ b/test/ps/output/Golden.LongApplyChain.Test/golden.lua @@ -1,9 +1,6 @@ local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} local Golden_LongApplyChain_Test_compute = { "Data.Maybe∷Maybe.Just", 300 } -return Effect_Console_foreign.log((function() +return (function(s) return function() print(s) end end)((function() if "Data.Maybe∷Maybe.Just" == Golden_LongApplyChain_Test_compute[1] then return "(Just " .. Data_Show_foreign.showIntImpl(Golden_LongApplyChain_Test_compute[2]) .. ")" else diff --git a/test/ps/output/Golden.LongBindFlipped.Test/golden.ir b/test/ps/output/Golden.LongBindFlipped.Test/golden.ir index adcbcba1..eb83fbd8 100644 --- a/test/ps/output/Golden.LongBindFlipped.Test/golden.ir +++ b/test/ps/output/Golden.LongBindFlipped.Test/golden.ir @@ -7,12 +7,6 @@ UberModule ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" [ ( Nothing, Name "showIntImpl" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Golden.LongBindFlipped.Test", qnameName = Name "inc" }, AbsN Nothing @@ -45,7 +39,10 @@ UberModule ), ( Name "main", AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( IfThenElse Nothing diff --git a/test/ps/output/Golden.LongBindFlipped.Test/golden.lua b/test/ps/output/Golden.LongBindFlipped.Test/golden.lua index d9ad25c4..ba8c4805 100644 --- a/test/ps/output/Golden.LongBindFlipped.Test/golden.lua +++ b/test/ps/output/Golden.LongBindFlipped.Test/golden.lua @@ -1,13 +1,10 @@ local M = {} local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} M.Golden_LongBindFlipped_Test_inc = function(x) return { "Data.Maybe∷Maybe.Just", x + 1 } end local Golden_LongBindFlipped_Test_compute = { "Data.Maybe∷Maybe.Just", 301 } -return Effect_Console_foreign.log((function() +return (function(s) return function() print(s) end end)((function() if "Data.Maybe∷Maybe.Just" == Golden_LongBindFlipped_Test_compute[1] then return "(Just " .. Data_Show_foreign.showIntImpl(Golden_LongBindFlipped_Test_compute[2]) .. ")" else diff --git a/test/ps/output/Golden.LongCallbackChain.Test/golden.ir b/test/ps/output/Golden.LongCallbackChain.Test/golden.ir index e5af8e67..b1ee1a38 100644 --- a/test/ps/output/Golden.LongCallbackChain.Test/golden.ir +++ b/test/ps/output/Golden.LongCallbackChain.Test/golden.ir @@ -1,18 +1,6 @@ UberModule { uberModuleBindings = - [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), RecursiveGroup + [ RecursiveGroup ( ( QName { qnameModuleName = ModuleName "Golden.LongCallbackChain.Test", qnameName = Name "withInc$w" @@ -5302,12 +5290,18 @@ UberModule ), ( Name "main", AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ) ( Ref Nothing diff --git a/test/ps/output/Golden.LongCallbackChain.Test/golden.lua b/test/ps/output/Golden.LongCallbackChain.Test/golden.lua index 0ebca057..bac99a81 100644 --- a/test/ps/output/Golden.LongCallbackChain.Test/golden.lua +++ b/test/ps/output/Golden.LongCallbackChain.Test/golden.lua @@ -1,8 +1,4 @@ local M = {} -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} local Golden_LongCallbackChain_Test_withInc_S_w = function(n, k) while true do if n < 0 then n, k = n + 1, k else return k(n + 1) end end end @@ -635,4 +631,6 @@ local Golden_LongCallbackChain_Test_compute = (function() end) end) end)() -return Effect_Console_foreign.log(Data_Show_foreign.showIntImpl(Golden_LongCallbackChain_Test_compute))() +return (function(s) return function() print(s) end end)((function(n) + return tostring(n) +end)(Golden_LongCallbackChain_Test_compute))() diff --git a/test/ps/output/Golden.LongDoBlock.Test/golden.ir b/test/ps/output/Golden.LongDoBlock.Test/golden.ir index 9fae446a..83f87dd9 100644 --- a/test/ps/output/Golden.LongDoBlock.Test/golden.ir +++ b/test/ps/output/Golden.LongDoBlock.Test/golden.ir @@ -1,16 +1,13 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ], uberModuleForeigns = [], uberModuleExports = diff --git a/test/ps/output/Golden.LongDoBlock.Test/golden.lua b/test/ps/output/Golden.LongDoBlock.Test/golden.lua index 6d51e0be..19896666 100644 --- a/test/ps/output/Golden.LongDoBlock.Test/golden.lua +++ b/test/ps/output/Golden.LongDoBlock.Test/golden.lua @@ -1,7 +1,4 @@ -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end return (function() local _ = Effect_Console_log("1")() local _ = Effect_Console_log("2")() diff --git a/test/ps/output/Golden.LongEitherBind.Test/golden.ir b/test/ps/output/Golden.LongEitherBind.Test/golden.ir index e6be8cb1..ab92b599 100644 --- a/test/ps/output/Golden.LongEitherBind.Test/golden.ir +++ b/test/ps/output/Golden.LongEitherBind.Test/golden.ir @@ -7,12 +7,6 @@ UberModule ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" [ ( Nothing, Name "showIntImpl" ), ( Nothing, Name "showStringImpl" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Golden.LongEitherBind.Test", qnameName = Name "compute" }, Ctor Nothing SumType @@ -36,7 +30,10 @@ UberModule ) ( AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( IfThenElse Nothing diff --git a/test/ps/output/Golden.LongEitherBind.Test/golden.lua b/test/ps/output/Golden.LongEitherBind.Test/golden.lua index c155c4e5..5088d602 100644 --- a/test/ps/output/Golden.LongEitherBind.Test/golden.lua +++ b/test/ps/output/Golden.LongEitherBind.Test/golden.lua @@ -40,17 +40,15 @@ local Data_Show_foreign = { return table.concat(out) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} local Golden_LongEitherBind_Test_compute = { "Data.Either∷Either.Right", 451 } return (function() local _S_cse0 = Golden_LongEitherBind_Test_compute[2] - return Effect_Console_foreign.log((function() + local s = (function() if "Data.Either∷Either.Left" == Golden_LongEitherBind_Test_compute[1] then return "(Left " .. Data_Show_foreign.showStringImpl(_S_cse0) .. ")" else return "(Right " .. Data_Show_foreign.showIntImpl(_S_cse0) .. ")" end - end)())() + end)() + print(s) end)() diff --git a/test/ps/output/Golden.LongExceptBind.Test/golden.ir b/test/ps/output/Golden.LongExceptBind.Test/golden.ir index 913c6d25..ae9ac1f9 100644 --- a/test/ps/output/Golden.LongExceptBind.Test/golden.ir +++ b/test/ps/output/Golden.LongExceptBind.Test/golden.ir @@ -7,12 +7,6 @@ UberModule ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" [ ( Nothing, Name "showIntImpl" ), ( Nothing, Name "showStringImpl" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Identity", qnameName = Name "applyIdentity" }, LiteralObject Nothing @@ -5774,7 +5768,10 @@ UberModule ) ( AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( IfThenElse Nothing diff --git a/test/ps/output/Golden.LongExceptBind.Test/golden.lua b/test/ps/output/Golden.LongExceptBind.Test/golden.lua index a19c24a9..0f54e953 100644 --- a/test/ps/output/Golden.LongExceptBind.Test/golden.lua +++ b/test/ps/output/Golden.LongExceptBind.Test/golden.lua @@ -40,9 +40,6 @@ local Data_Show_foreign = { return table.concat(out) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} local Data_Identity_applyIdentity = { apply = function(v) return function(v1) return v(v1) end end, Functor0 = function() @@ -1163,11 +1160,12 @@ local Golden_LongExceptBind_Test_go = (function() end)() return (function() local _S_cse2 = Golden_LongExceptBind_Test_go[2] - return Effect_Console_foreign.log((function() + local s = (function() if "Data.Either∷Either.Left" == Golden_LongExceptBind_Test_go[1] then return "(Left " .. Data_Show_foreign.showStringImpl(_S_cse2) .. ")" else return "(Right " .. Data_Show_foreign.showIntImpl(_S_cse2) .. ")" end - end)())() + end)() + print(s) end)() diff --git a/test/ps/output/Golden.LongMaybeBind.Test/golden.ir b/test/ps/output/Golden.LongMaybeBind.Test/golden.ir index b6dbbd97..c4d82a6b 100644 --- a/test/ps/output/Golden.LongMaybeBind.Test/golden.ir +++ b/test/ps/output/Golden.LongMaybeBind.Test/golden.ir @@ -7,12 +7,6 @@ UberModule ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" [ ( Nothing, Name "showIntImpl" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Golden.LongMaybeBind.Test", qnameName = Name "compute" }, Ctor Nothing SumType @@ -28,7 +22,10 @@ UberModule ), ( Name "main", AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( IfThenElse Nothing diff --git a/test/ps/output/Golden.LongMaybeBind.Test/golden.lua b/test/ps/output/Golden.LongMaybeBind.Test/golden.lua index 85c49452..bb1962f1 100644 --- a/test/ps/output/Golden.LongMaybeBind.Test/golden.lua +++ b/test/ps/output/Golden.LongMaybeBind.Test/golden.lua @@ -1,9 +1,6 @@ local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} local Golden_LongMaybeBind_Test_compute = { "Data.Maybe∷Maybe.Just", 301 } -return Effect_Console_foreign.log((function() +return (function(s) return function() print(s) end end)((function() if "Data.Maybe∷Maybe.Just" == Golden_LongMaybeBind_Test_compute[1] then return "(Just " .. Data_Show_foreign.showIntImpl(Golden_LongMaybeBind_Test_compute[2]) .. ")" else diff --git a/test/ps/output/Golden.LongReaderBind.Test/golden.ir b/test/ps/output/Golden.LongReaderBind.Test/golden.ir index 8dcf78f1..7f910755 100644 --- a/test/ps/output/Golden.LongReaderBind.Test/golden.ir +++ b/test/ps/output/Golden.LongReaderBind.Test/golden.ir @@ -1,18 +1,6 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Golden.LongReaderBind.Test", qnameName = Name "go" }, AbsN Nothing @@ -33,12 +21,18 @@ UberModule ( Name "compute", LiteralInt Nothing 9 ), ( Name "main", AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ) ( LiteralInt Nothing 9 :| [] ) :| [] diff --git a/test/ps/output/Golden.LongReaderBind.Test/golden.lua b/test/ps/output/Golden.LongReaderBind.Test/golden.lua index 44423453..8bc18c13 100644 --- a/test/ps/output/Golden.LongReaderBind.Test/golden.lua +++ b/test/ps/output/Golden.LongReaderBind.Test/golden.lua @@ -1,9 +1,7 @@ local M = {} -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} M.Golden_LongReaderBind_Test_go = function(r_S_0) return r_S_0 + r_S_0 + r_S_0 end -return Effect_Console_foreign.log(Data_Show_foreign.showIntImpl(9))() +return (function(s) return function() print(s) end end)((function(n) + return tostring(n) +end)(9))() diff --git a/test/ps/output/Golden.LongStackBind.Test/golden.ir b/test/ps/output/Golden.LongStackBind.Test/golden.ir index 68a6be79..7083e8b6 100644 --- a/test/ps/output/Golden.LongStackBind.Test/golden.ir +++ b/test/ps/output/Golden.LongStackBind.Test/golden.ir @@ -1,16 +1,13 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" - [ ( Just Never, Name "unit" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "unit" }, ObjectProp ( Just Never ) - ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" + [ ( Just Never, Name "unit" ) ] + ) ( PropName "unit" ) ), Standalone ( QName @@ -19,12 +16,6 @@ UberModule ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" [ ( Nothing, Name "showIntImpl" ), ( Nothing, Name "showStringImpl" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Control.Monad", qnameName = Name "ap" }, AbsN Nothing ( ParamNamed Nothing ( Name "dictMonad" ) :| [] ) @@ -12912,7 +12903,10 @@ UberModule ) ( AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( IfThenElse Nothing diff --git a/test/ps/output/Golden.LongStackBind.Test/golden.lua b/test/ps/output/Golden.LongStackBind.Test/golden.lua index fa885b4a..fa691bf7 100644 --- a/test/ps/output/Golden.LongStackBind.Test/golden.lua +++ b/test/ps/output/Golden.LongStackBind.Test/golden.lua @@ -1,5 +1,4 @@ -local Data_Unit_foreign = { unit = {} } -local Data_Unit_unit = Data_Unit_foreign.unit +local Data_Unit_unit = {} local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end, showStringImpl = function(s) @@ -42,9 +41,6 @@ local Data_Show_foreign = { return table.concat(out) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} local Control_Monad_ap = function(dictMonad) local bind = (dictMonad.Bind1()).bind return function(f) @@ -1603,11 +1599,12 @@ local Golden_LongStackBind_Test_compute = (function() end)() return (function() local _S_cse2 = Golden_LongStackBind_Test_compute[2] - return Effect_Console_foreign.log((function() + local s = (function() if "Data.Either∷Either.Left" == Golden_LongStackBind_Test_compute[1] then return "(Left " .. Data_Show_foreign.showStringImpl(_S_cse2) .. ")" else return "(Right " .. Data_Show_foreign.showIntImpl(_S_cse2) .. ")" end - end)())() + end)() + print(s) end)() diff --git a/test/ps/output/Golden.LongStateBind.Test/golden.ir b/test/ps/output/Golden.LongStateBind.Test/golden.ir index aa98c44a..1a830bdf 100644 --- a/test/ps/output/Golden.LongStateBind.Test/golden.ir +++ b/test/ps/output/Golden.LongStateBind.Test/golden.ir @@ -1,30 +1,15 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" - [ ( Just Never, Name "unit" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "unit" }, ObjectProp ( Just Never ) - ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" + [ ( Just Never, Name "unit" ) ] + ) ( PropName "unit" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Identity", qnameName = Name "applyIdentity" }, LiteralObject Nothing @@ -9327,12 +9312,18 @@ UberModule ), ( Name "main", AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ) ( Ref Nothing diff --git a/test/ps/output/Golden.LongStateBind.Test/golden.lua b/test/ps/output/Golden.LongStateBind.Test/golden.lua index 83b940a0..c90f872c 100644 --- a/test/ps/output/Golden.LongStateBind.Test/golden.lua +++ b/test/ps/output/Golden.LongStateBind.Test/golden.lua @@ -1,9 +1,4 @@ -local Data_Unit_foreign = { unit = {} } -local Data_Unit_unit = Data_Unit_foreign.unit -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} +local Data_Unit_unit = {} local Data_Identity_applyIdentity = { apply = function(v) return function(v1) return v(v1) end end, Functor0 = function() @@ -1233,4 +1228,6 @@ local Golden_LongStateBind_Test_go = (function() end) end)() local Golden_LongStateBind_Test_compute = (Golden_LongStateBind_Test_go(0))[1] -return Effect_Console_foreign.log(Data_Show_foreign.showIntImpl(Golden_LongStateBind_Test_compute))() +return (function(s) return function() print(s) end end)((function(n) + return tostring(n) +end)(Golden_LongStateBind_Test_compute))() diff --git a/test/ps/output/Golden.LongWriterBind.Test/golden.ir b/test/ps/output/Golden.LongWriterBind.Test/golden.ir index 84ce17a1..59f2e51c 100644 --- a/test/ps/output/Golden.LongWriterBind.Test/golden.ir +++ b/test/ps/output/Golden.LongWriterBind.Test/golden.ir @@ -1,16 +1,13 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" - [ ( Just Never, Name "unit" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "unit" }, ObjectProp ( Just Never ) - ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" + [ ( Just Never, Name "unit" ) ] + ) ( PropName "unit" ) ), Standalone ( QName @@ -19,18 +16,6 @@ UberModule ( ModuleName "Data.Semigroup" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Semigroup.purs" [ ( Nothing, Name "concatArray" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Identity", qnameName = Name "applyIdentity" }, LiteralObject Nothing @@ -4474,12 +4459,18 @@ UberModule ), ( Name "main", AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ) ( Ref Nothing diff --git a/test/ps/output/Golden.LongWriterBind.Test/golden.lua b/test/ps/output/Golden.LongWriterBind.Test/golden.lua index 0182daad..fd3414af 100644 --- a/test/ps/output/Golden.LongWriterBind.Test/golden.lua +++ b/test/ps/output/Golden.LongWriterBind.Test/golden.lua @@ -1,5 +1,4 @@ -local Data_Unit_foreign = { unit = {} } -local Data_Unit_unit = Data_Unit_foreign.unit +local Data_Unit_unit = {} local Data_Semigroup_foreign = { concatArray = function(xs) return function(ys) @@ -13,10 +12,6 @@ local Data_Semigroup_foreign = { end end } -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} local Data_Identity_applyIdentity = { apply = function(v) return function(v1) return v(v1) end end, Functor0 = function() @@ -847,4 +842,6 @@ local Golden_LongWriterBind_Test_go = (function() end) end)() local Golden_LongWriterBind_Test_compute = Golden_LongWriterBind_Test_go[1] -return Effect_Console_foreign.log(Data_Show_foreign.showIntImpl(Golden_LongWriterBind_Test_compute))() +return (function(s) return function() print(s) end end)((function(n) + return tostring(n) +end)(Golden_LongWriterBind_Test_compute))() diff --git a/test/ps/output/Golden.MaybeChain.Test/golden.ir b/test/ps/output/Golden.MaybeChain.Test/golden.ir index 50ae32d2..fbb35056 100644 --- a/test/ps/output/Golden.MaybeChain.Test/golden.ir +++ b/test/ps/output/Golden.MaybeChain.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.MaybeChain.Test/golden.lua b/test/ps/output/Golden.MaybeChain.Test/golden.lua index 5849a12e..efbae158 100644 --- a/test/ps/output/Golden.MaybeChain.Test/golden.lua +++ b/test/ps/output/Golden.MaybeChain.Test/golden.lua @@ -1,9 +1,5 @@ -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end local Data_Maybe_Nothing = { "Data.Maybe∷Maybe.Nothing" } return (function() local _ = Effect_Console_log(Data_Show_showIntImpl((function() diff --git a/test/ps/output/Golden.MixedDiscardFloat.Test/golden.ir b/test/ps/output/Golden.MixedDiscardFloat.Test/golden.ir index 0ba6205e..c04a1f94 100644 --- a/test/ps/output/Golden.MixedDiscardFloat.Test/golden.ir +++ b/test/ps/output/Golden.MixedDiscardFloat.Test/golden.ir @@ -1,16 +1,13 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" - [ ( Just Never, Name "unit" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "unit" }, ObjectProp ( Just Never ) - ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" + [ ( Just Never, Name "unit" ) ] + ) ( PropName "unit" ) ), Standalone ( QName @@ -32,16 +29,13 @@ UberModule ( Nothing, Name "write" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.MixedDiscardFloat.Test/golden.lua b/test/ps/output/Golden.MixedDiscardFloat.Test/golden.lua index 795a741a..542e5af3 100644 --- a/test/ps/output/Golden.MixedDiscardFloat.Test/golden.lua +++ b/test/ps/output/Golden.MixedDiscardFloat.Test/golden.lua @@ -1,6 +1,5 @@ local M = {} -local Data_Unit_foreign = { unit = {} } -M.Data_Unit_unit = Data_Unit_foreign.unit +M.Data_Unit_unit = {} local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } local Control_Monad_ST_Internal_foreign = { map_ = function(f) @@ -16,10 +15,7 @@ local Control_Monad_ST_Internal_foreign = { return function(ref) return function() ref.value = a return a end end end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end local Golden_MixedDiscardFloat_Test_stCount = Control_Monad_ST_Internal_foreign.run(function( ) local r = 1 r = 2 diff --git a/test/ps/output/Golden.MixedEffectSTDo.Test/golden.ir b/test/ps/output/Golden.MixedEffectSTDo.Test/golden.ir index 79035342..f92f7d4c 100644 --- a/test/ps/output/Golden.MixedEffectSTDo.Test/golden.ir +++ b/test/ps/output/Golden.MixedEffectSTDo.Test/golden.ir @@ -20,16 +20,13 @@ UberModule ( Nothing, Name "modifyImpl" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.MixedEffectSTDo.Test/golden.lua b/test/ps/output/Golden.MixedEffectSTDo.Test/golden.lua index 4ff0400e..e4216943 100644 --- a/test/ps/output/Golden.MixedEffectSTDo.Test/golden.lua +++ b/test/ps/output/Golden.MixedEffectSTDo.Test/golden.lua @@ -17,10 +17,7 @@ local Control_Monad_ST_Internal_foreign = { end end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end local Golden_MixedEffectSTDo_Test_tally = function(start) return Control_Monad_ST_Internal_foreign.run(function() local ref = start diff --git a/test/ps/output/Golden.MutualLoopification.Test/golden.ir b/test/ps/output/Golden.MutualLoopification.Test/golden.ir index 742804ba..74b926d0 100644 --- a/test/ps/output/Golden.MutualLoopification.Test/golden.ir +++ b/test/ps/output/Golden.MutualLoopification.Test/golden.ir @@ -7,16 +7,13 @@ UberModule ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" [ ( Nothing, Name "showIntImpl" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.MutualLoopification.Test/golden.lua b/test/ps/output/Golden.MutualLoopification.Test/golden.lua index 6e320863..973578a9 100644 --- a/test/ps/output/Golden.MutualLoopification.Test/golden.lua +++ b/test/ps/output/Golden.MutualLoopification.Test/golden.lua @@ -1,9 +1,6 @@ local M = {} local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end local Golden_MutualLoopification_Test_logShow = function(a_S_0) return Effect_Console_log((function() if a_S_0 then return "true" else return "false" end diff --git a/test/ps/output/Golden.NativeLoops.Test/golden.ir b/test/ps/output/Golden.NativeLoops.Test/golden.ir index 48c3730e..1b4525be 100644 --- a/test/ps/output/Golden.NativeLoops.Test/golden.ir +++ b/test/ps/output/Golden.NativeLoops.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" - [ ( Just Never, Name "unit" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "unit" }, ObjectProp ( Just Never ) - ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" + [ ( Just Never, Name "unit" ) ] + ) ( PropName "unit" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone ( QName @@ -47,16 +41,13 @@ UberModule ( Ref Nothing ( Imported ( ModuleName "Effect" ) ( Name "foreign" ) ) ) ( PropName "foreachE" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.NativeLoops.Test/golden.lua b/test/ps/output/Golden.NativeLoops.Test/golden.lua index e9d59c59..9ead688a 100644 --- a/test/ps/output/Golden.NativeLoops.Test/golden.lua +++ b/test/ps/output/Golden.NativeLoops.Test/golden.lua @@ -17,10 +17,8 @@ local function PSLUA_runtime_lazy(name) end end local M = {} -local Data_Unit_foreign = { unit = {} } -local Data_Unit_unit = Data_Unit_foreign.unit -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl +local Data_Unit_unit = {} +local Data_Show_showIntImpl = function(n) return tostring(n) end local Effect_foreign = { pureE = function(a) return function() return a end end, bindE = function(a) @@ -44,10 +42,7 @@ local Effect_foreign = { } M.Effect_forE = Effect_foreign.forE M.Effect_foreachE = Effect_foreign.foreachE -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end local Effect_Ref_foreign = { _new = function(val) return function() return { value = val } end end, read = function(ref) return function() return ref.value end end, diff --git a/test/ps/output/Golden.NativeLoopsAliasPin.Test/golden.ir b/test/ps/output/Golden.NativeLoopsAliasPin.Test/golden.ir index 8cb88de5..316a257e 100644 --- a/test/ps/output/Golden.NativeLoopsAliasPin.Test/golden.ir +++ b/test/ps/output/Golden.NativeLoopsAliasPin.Test/golden.ir @@ -7,22 +7,13 @@ UberModule ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" [ ( Nothing, Name "showIntImpl" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect" ) ".spago/p/effect/82bac3dff904fa34534c4f5b9deeb5da359471c8/src/Effect.purs" - [ ( Nothing, Name "bindE" ), ( Nothing, Name "forE" ) ] - ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName @@ -43,7 +34,10 @@ UberModule ( QName { qnameModuleName = ModuleName "Golden.NativeLoopsAliasPin.Test", qnameName = Name "myFor" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect" ) ".spago/p/effect/82bac3dff904fa34534c4f5b9deeb5da359471c8/src/Effect.purs" + [ ( Nothing, Name "bindE" ), ( Nothing, Name "forE" ) ] + ) ( PropName "forE" ) ) ], uberModuleForeigns = [], uberModuleExports = diff --git a/test/ps/output/Golden.NativeLoopsAliasPin.Test/golden.lua b/test/ps/output/Golden.NativeLoopsAliasPin.Test/golden.lua index 2113477b..d3edca2a 100644 --- a/test/ps/output/Golden.NativeLoopsAliasPin.Test/golden.lua +++ b/test/ps/output/Golden.NativeLoopsAliasPin.Test/golden.lua @@ -1,24 +1,15 @@ local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Effect_foreign = { - bindE = function(a) - return function(f) return function() return f(a())() end end - end, - forE = function(lo) - return function(hi) - return function(f) - return function() for i = lo, hi - 1 do f(i)() end end - end - end - end -} -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end local Golden_NativeLoopsAliasPin_Test_logShow = function(a_S_0) return Effect_Console_log(Data_Show_foreign.showIntImpl(a_S_0)) end -local Golden_NativeLoopsAliasPin_Test_myFor = Effect_foreign.forE +local Golden_NativeLoopsAliasPin_Test_myFor = function(lo) + return function(hi) + return function(f) + return function() for i = lo, hi - 1 do f(i)() end end + end + end +end return (function() local _ = Effect_Console_log("first:")() local _ = Golden_NativeLoopsAliasPin_Test_myFor(1)(3)(Golden_NativeLoopsAliasPin_Test_logShow)() diff --git a/test/ps/output/Golden.NativeLoopsGuard.Test/golden.ir b/test/ps/output/Golden.NativeLoopsGuard.Test/golden.ir index c6cd7b17..0c0873b1 100644 --- a/test/ps/output/Golden.NativeLoopsGuard.Test/golden.ir +++ b/test/ps/output/Golden.NativeLoopsGuard.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" - [ ( Just Never, Name "unit" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "unit" }, ObjectProp ( Just Never ) - ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" + [ ( Just Never, Name "unit" ) ] + ) ( PropName "unit" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone ( QName @@ -53,16 +47,13 @@ UberModule ( ModuleName "Data.Array" ) ".spago/p/arrays/4641b4b5ee19c3b472151da585f4676147a7cd74/src/Data/Array.purs" [ ( Nothing, Name "indexImpl" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), RecursiveGroup ( diff --git a/test/ps/output/Golden.NativeLoopsGuard.Test/golden.lua b/test/ps/output/Golden.NativeLoopsGuard.Test/golden.lua index 5302271e..b733a5d9 100644 --- a/test/ps/output/Golden.NativeLoopsGuard.Test/golden.lua +++ b/test/ps/output/Golden.NativeLoopsGuard.Test/golden.lua @@ -16,10 +16,8 @@ local function PSLUA_runtime_lazy(name) end end end -local Data_Unit_foreign = { unit = {} } -local Data_Unit_unit = Data_Unit_foreign.unit -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl +local Data_Unit_unit = {} +local Data_Show_showIntImpl = function(n) return tostring(n) end local Effect_foreign = { pureE = function(a) return function() return a end end, bindE = function(a) @@ -46,10 +44,7 @@ local Data_Array_foreign = { if i < 0 or i >= #(xs) then return nothing else return just(xs[i + 1]) end end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end local Effect_bindEffect local Effect_applicativeEffect local Effect_monadEffect = { diff --git a/test/ps/output/Golden.NativeLoopsST.Test/golden.ir b/test/ps/output/Golden.NativeLoopsST.Test/golden.ir index 5264dd58..bfb92b16 100644 --- a/test/ps/output/Golden.NativeLoopsST.Test/golden.ir +++ b/test/ps/output/Golden.NativeLoopsST.Test/golden.ir @@ -1,16 +1,13 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" - [ ( Just Never, Name "unit" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "unit" }, ObjectProp ( Just Never ) - ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" + [ ( Just Never, Name "unit" ) ] + ) ( PropName "unit" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.NativeLoopsST.Test/golden.lua b/test/ps/output/Golden.NativeLoopsST.Test/golden.lua index aa5fb9d4..02d45d59 100644 --- a/test/ps/output/Golden.NativeLoopsST.Test/golden.lua +++ b/test/ps/output/Golden.NativeLoopsST.Test/golden.lua @@ -1,6 +1,5 @@ local M = {} -local Data_Unit_foreign = { unit = {} } -M.Data_Unit_unit = Data_Unit_foreign.unit +M.Data_Unit_unit = {} local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } local Control_Monad_ST_Internal_foreign = { map_ = function(f) diff --git a/test/ps/output/Golden.NumberIsNaN.Test/golden.ir b/test/ps/output/Golden.NumberIsNaN.Test/golden.ir index 60db1d8d..84ee5b0e 100644 --- a/test/ps/output/Golden.NumberIsNaN.Test/golden.ir +++ b/test/ps/output/Golden.NumberIsNaN.Test/golden.ir @@ -1,15 +1,12 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Ring", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Ring" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Ring.purs" - [ ( Nothing, Name "numSub" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Ring", qnameName = Name "numSub" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Ring" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Ring" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Ring.purs" + [ ( Nothing, Name "numSub" ) ] + ) ( PropName "numSub" ) ), Standalone ( QName @@ -35,16 +32,13 @@ UberModule ( Ref Nothing ( Imported ( ModuleName "Data.Number" ) ( Name "foreign" ) ) ) ( PropName "nan" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ], uberModuleForeigns = [], uberModuleExports = diff --git a/test/ps/output/Golden.NumberIsNaN.Test/golden.lua b/test/ps/output/Golden.NumberIsNaN.Test/golden.lua index ed72df24..431c5190 100644 --- a/test/ps/output/Golden.NumberIsNaN.Test/golden.lua +++ b/test/ps/output/Golden.NumberIsNaN.Test/golden.lua @@ -1,7 +1,4 @@ -local Data_Ring_foreign = { - numSub = function(x) return function(y) return x - y end end -} -local Data_Ring_numSub = Data_Ring_foreign.numSub +local Data_Ring_numSub = function(x) return function(y) return x - y end end local Data_Number_foreign = { nan = 0 / 0, isNaN = function(x) return x ~= x end, @@ -10,10 +7,7 @@ local Data_Number_foreign = { local Data_Number_infinity = Data_Number_foreign.infinity local Data_Number_isNaN = Data_Number_foreign.isNaN local Data_Number_nan = Data_Number_foreign.nan -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end return (function() local _ = Effect_Console_log((function() if Data_Number_isNaN(Data_Number_nan) then diff --git a/test/ps/output/Golden.Primops.Test/golden.ir b/test/ps/output/Golden.Primops.Test/golden.ir index 201c61c0..a41bd032 100644 --- a/test/ps/output/Golden.Primops.Test/golden.ir +++ b/test/ps/output/Golden.Primops.Test/golden.ir @@ -7,16 +7,13 @@ UberModule ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" [ ( Nothing, Name "showIntImpl" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), RecursiveGroup ( diff --git a/test/ps/output/Golden.Primops.Test/golden.lua b/test/ps/output/Golden.Primops.Test/golden.lua index c97d4ec8..285aa814 100644 --- a/test/ps/output/Golden.Primops.Test/golden.lua +++ b/test/ps/output/Golden.Primops.Test/golden.lua @@ -1,9 +1,6 @@ local M = {} local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end local Data_HeytingAlgebra_heytingAlgebraBoolean Data_HeytingAlgebra_heytingAlgebraBoolean = { ff = false, diff --git a/test/ps/output/Golden.ProfunctorDictLens.Test/golden.ir b/test/ps/output/Golden.ProfunctorDictLens.Test/golden.ir index cbdf68d2..b42c41dd 100644 --- a/test/ps/output/Golden.ProfunctorDictLens.Test/golden.ir +++ b/test/ps/output/Golden.ProfunctorDictLens.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.ProfunctorDictLens.Test/golden.lua b/test/ps/output/Golden.ProfunctorDictLens.Test/golden.lua index 92842e1c..1be70cbc 100644 --- a/test/ps/output/Golden.ProfunctorDictLens.Test/golden.lua +++ b/test/ps/output/Golden.ProfunctorDictLens.Test/golden.lua @@ -1,10 +1,6 @@ local M = {} -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end local Data_Newtype_coerce = function(x_S_0) return x_S_0 end local Golden_ProfunctorDictLens_Test_unwrap = Data_Newtype_coerce local Golden_ProfunctorDictLens_Test_Wrapped = function(x) return x end diff --git a/test/ps/output/Golden.RecGroupOrder.Test/golden.ir b/test/ps/output/Golden.RecGroupOrder.Test/golden.ir index 0f2df955..b3ead94f 100644 --- a/test/ps/output/Golden.RecGroupOrder.Test/golden.ir +++ b/test/ps/output/Golden.RecGroupOrder.Test/golden.ir @@ -1,24 +1,15 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" - [ ( Just Never, Name "unit" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "unit" }, ObjectProp ( Just Never ) - ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Unit.purs" + [ ( Just Never, Name "unit" ) ] + ) ( PropName "unit" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Golden.RecGroupOrder.Test", qnameName = Name "store" }, AbsN Nothing @@ -72,7 +63,10 @@ UberModule ) ( AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( AppN Nothing diff --git a/test/ps/output/Golden.RecGroupOrder.Test/golden.lua b/test/ps/output/Golden.RecGroupOrder.Test/golden.lua index e89aab29..f20fc603 100644 --- a/test/ps/output/Golden.RecGroupOrder.Test/golden.lua +++ b/test/ps/output/Golden.RecGroupOrder.Test/golden.lua @@ -17,11 +17,7 @@ local function PSLUA_runtime_lazy(name) end end local M = {} -local Data_Unit_foreign = { unit = {} } -local Data_Unit_unit = Data_Unit_foreign.unit -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} +local Data_Unit_unit = {} M.Golden_RecGroupOrder_Test_store = function(f) return { run = f, tag = "ok!" } end @@ -32,5 +28,6 @@ return (function() return { run = function() return (Lazy_record_S_0(0)).tag end, tag = "ok!" } end) record_S_0 = Lazy_record_S_0(0) - return Effect_Console_foreign.log(record_S_0.run(Data_Unit_unit))() + local s = record_S_0.run(Data_Unit_unit) + print(s) end)() diff --git a/test/ps/output/Golden.RecordSurgery.Test/golden.ir b/test/ps/output/Golden.RecordSurgery.Test/golden.ir index ac127e1c..86231081 100644 --- a/test/ps/output/Golden.RecordSurgery.Test/golden.ir +++ b/test/ps/output/Golden.RecordSurgery.Test/golden.ir @@ -17,16 +17,13 @@ UberModule ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" [ ( Nothing, Name "showIntImpl" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.RecordSurgery.Test/golden.lua b/test/ps/output/Golden.RecordSurgery.Test/golden.lua index 2dfe1b8c..11c40d50 100644 --- a/test/ps/output/Golden.RecordSurgery.Test/golden.lua +++ b/test/ps/output/Golden.RecordSurgery.Test/golden.lua @@ -20,10 +20,7 @@ local Record_Unsafe_foreign = { end } local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end M.Effect_Ref_foreign = { _new = function(val) return function() return { value = val } end end, read = function(ref) return function() return ref.value end end diff --git a/test/ps/output/Golden.STDoBlock.Test/golden.ir b/test/ps/output/Golden.STDoBlock.Test/golden.ir index 5ffc31f0..c55a0de6 100644 --- a/test/ps/output/Golden.STDoBlock.Test/golden.ir +++ b/test/ps/output/Golden.STDoBlock.Test/golden.ir @@ -1,12 +1,6 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Control.Monad.ST.Internal", qnameName = Name "foreign" }, ForeignImport Nothing @@ -26,12 +20,6 @@ UberModule ( Ref Nothing ( Imported ( ModuleName "Control.Monad.ST.Internal" ) ( Name "foreign" ) ) ) ( PropName "modifyImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Golden.STDoBlock.Test", qnameName = Name "sumTwice" }, AbsN Nothing @@ -149,12 +137,18 @@ UberModule ), ( Name "main", AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ) ( AppN Nothing diff --git a/test/ps/output/Golden.STDoBlock.Test/golden.lua b/test/ps/output/Golden.STDoBlock.Test/golden.lua index 3e9fc5d5..f14ab7d7 100644 --- a/test/ps/output/Golden.STDoBlock.Test/golden.lua +++ b/test/ps/output/Golden.STDoBlock.Test/golden.lua @@ -1,5 +1,4 @@ local M = {} -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } local Control_Monad_ST_Internal_foreign = { pure_ = function(a) return function() return a end end, bind_ = function(a) @@ -19,9 +18,6 @@ local Control_Monad_ST_Internal_foreign = { end } M.Control_Monad_ST_Internal_modifyImpl = Control_Monad_ST_Internal_foreign.modifyImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} local Golden_STDoBlock_Test_sumTwice = function(n) return Control_Monad_ST_Internal_foreign.run(function() local _S_cse0 = function(s_S_0) @@ -35,4 +31,6 @@ local Golden_STDoBlock_Test_sumTwice = function(n) return total + 1 end) end -return Effect_Console_foreign.log(Data_Show_foreign.showIntImpl(Golden_STDoBlock_Test_sumTwice(5)))() +return (function(s) return function() print(s) end end)((function(n) + return tostring(n) +end)(Golden_STDoBlock_Test_sumTwice(5)))() diff --git a/test/ps/output/Golden.ScalarReplacement.Test/golden.ir b/test/ps/output/Golden.ScalarReplacement.Test/golden.ir index fd375301..a13172c6 100644 --- a/test/ps/output/Golden.ScalarReplacement.Test/golden.ir +++ b/test/ps/output/Golden.ScalarReplacement.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.ScalarReplacement.Test/golden.lua b/test/ps/output/Golden.ScalarReplacement.Test/golden.lua index 5c98054a..3bb23ae8 100644 --- a/test/ps/output/Golden.ScalarReplacement.Test/golden.lua +++ b/test/ps/output/Golden.ScalarReplacement.Test/golden.lua @@ -7,12 +7,8 @@ local function PSLUA_object_update(o, patches) return o_copy end local M = {} -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end local Golden_ScalarReplacement_Test_wholeValue = function(n) local r = { a = n, b = n + 1 } local s = (function() diff --git a/test/ps/output/Golden.SpecConstr.Test/golden.ir b/test/ps/output/Golden.SpecConstr.Test/golden.ir index 872c9127..307c9ce7 100644 --- a/test/ps/output/Golden.SpecConstr.Test/golden.ir +++ b/test/ps/output/Golden.SpecConstr.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.SpecConstr.Test/golden.lua b/test/ps/output/Golden.SpecConstr.Test/golden.lua index a672cbd1..c8ab515c 100644 --- a/test/ps/output/Golden.SpecConstr.Test/golden.lua +++ b/test/ps/output/Golden.SpecConstr.Test/golden.lua @@ -1,10 +1,6 @@ local M = {} -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end M.Golden_SpecConstr_Test_sumCount = function(n) local go_S_sc1Tuple_S_f1, go_S_sc1Tuple_S_f2 go_S_sc1Tuple_S_f1, go_S_sc1Tuple_S_f2 = 0, 0 diff --git a/test/ps/output/Golden.StringCodePoints.Test/golden.ir b/test/ps/output/Golden.StringCodePoints.Test/golden.ir index a5b71e5a..85bdeb59 100644 --- a/test/ps/output/Golden.StringCodePoints.Test/golden.ir +++ b/test/ps/output/Golden.StringCodePoints.Test/golden.ir @@ -49,16 +49,13 @@ UberModule ( ModuleName "Data.EuclideanRing" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/EuclideanRing.purs" [ ( Nothing, Name "intDegree" ), ( Nothing, Name "intDiv" ), ( Nothing, Name "intMod" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Partial.Unsafe", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Partial.Unsafe" ) ".spago/p/partial/2f5c69b1de8f88f1fbc9b98281c9436088ae0789/src/Partial/Unsafe.purs" - [ ( Nothing, Name "_unsafePartial" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Partial.Unsafe", qnameName = Name "_unsafePartial" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Partial.Unsafe" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Partial.Unsafe" ) ".spago/p/partial/2f5c69b1de8f88f1fbc9b98281c9436088ae0789/src/Partial/Unsafe.purs" + [ ( Nothing, Name "_unsafePartial" ) ] + ) ( PropName "_unsafePartial" ) ), Standalone ( QName @@ -79,16 +76,13 @@ UberModule ( Ref Nothing ( Imported ( ModuleName "Data.Enum" ) ( Name "foreign" ) ) ) ( PropName "toCharCode" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Data.String.Unsafe", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.String.Unsafe" ) ".spago/p/strings/395c4b6cb74271b5570a1d7632fb6522785792af/src/Data/String/Unsafe.purs" - [ ( Nothing, Name "charAt" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.String.Unsafe", qnameName = Name "charAt" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.String.Unsafe" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.String.Unsafe" ) ".spago/p/strings/395c4b6cb74271b5570a1d7632fb6522785792af/src/Data/String/Unsafe.purs" + [ ( Nothing, Name "charAt" ) ] + ) ( PropName "charAt" ) ), Standalone ( QName @@ -110,16 +104,13 @@ UberModule ( Nothing, Name "_unsafeCodePointAt0" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), RecursiveGroup ( diff --git a/test/ps/output/Golden.StringCodePoints.Test/golden.lua b/test/ps/output/Golden.StringCodePoints.Test/golden.lua index 12f98f8f..b2883114 100644 --- a/test/ps/output/Golden.StringCodePoints.Test/golden.lua +++ b/test/ps/output/Golden.StringCodePoints.Test/golden.lua @@ -69,8 +69,7 @@ local Data_EuclideanRing_foreign = { end end } -local Partial_Unsafe_foreign = { _unsafePartial = function(f) return f() end } -local Partial_Unsafe__unsafePartial = Partial_Unsafe_foreign._unsafePartial +local Partial_Unsafe__unsafePartial = function(f) return f() end local Data_Unfoldable_foreign = { unfoldrArrayImpl = function(isNothing) return function(fromJust) @@ -128,15 +127,12 @@ local Data_Enum_foreign = { end } local Data_Enum_toCharCode = Data_Enum_foreign.toCharCode -local Data_String_Unsafe_foreign = { - charAt = function(i) - return function(s) - if i >= 0 and i < #(s) then return s:sub(i + 1, i + 1) end - error("Data.String.Unsafe.charAt: Invalid index.") - end +local Data_String_Unsafe_charAt = function(i) + return function(s) + if i >= 0 and i < #(s) then return s:sub(i + 1, i + 1) end + error("Data.String.Unsafe.charAt: Invalid index.") end -} -local Data_String_Unsafe_charAt = Data_String_Unsafe_foreign.charAt +end local Data_String_CodeUnits_foreign = { -- PureScript indices are 0-based, Lua string positions are 1-based; -- the exports below convert between the two. Pattern arguments are @@ -251,10 +247,7 @@ local Data_String_CodePoints_foreign = (function() end } end)() -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end local Data_HeytingAlgebra_heytingAlgebraBoolean Data_HeytingAlgebra_heytingAlgebraBoolean = { ff = false, diff --git a/test/ps/output/Golden.StringEscapes.Test/golden.ir b/test/ps/output/Golden.StringEscapes.Test/golden.ir index 32b69abb..f7aec2d2 100644 --- a/test/ps/output/Golden.StringEscapes.Test/golden.ir +++ b/test/ps/output/Golden.StringEscapes.Test/golden.ir @@ -1,17 +1,12 @@ UberModule - { uberModuleBindings = - [ Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ) - ], uberModuleForeigns = [], uberModuleExports = + { uberModuleBindings = [], uberModuleForeigns = [], uberModuleExports = [ ( Name "main", AppN Nothing ( ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ) ( LiteralString Nothing "\27[31mred\27[0m" :| [] ) diff --git a/test/ps/output/Golden.StringEscapes.Test/golden.lua b/test/ps/output/Golden.StringEscapes.Test/golden.lua index bb977b68..1b4f996b 100644 --- a/test/ps/output/Golden.StringEscapes.Test/golden.lua +++ b/test/ps/output/Golden.StringEscapes.Test/golden.lua @@ -1,4 +1 @@ -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -return Effect_Console_foreign.log("\27[31mred\27[0m")() +return (function(s) return function() print(s) end end)("\27[31mred\27[0m")() diff --git a/test/ps/output/Golden.TestReturnTableField/golden.ir b/test/ps/output/Golden.TestReturnTableField/golden.ir index 56759349..b0608921 100644 --- a/test/ps/output/Golden.TestReturnTableField/golden.ir +++ b/test/ps/output/Golden.TestReturnTableField/golden.ir @@ -1,17 +1,10 @@ UberModule - { uberModuleBindings = - [ Standalone - ( QName - { qnameModuleName = ModuleName "Golden.TestReturnTableField", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Golden.TestReturnTableField" ) "src/Golden/ReturnTableField/Test.purs" - [ ( Nothing, Name "u" ) ] - ) - ], uberModuleForeigns = [], uberModuleExports = + { uberModuleBindings = [], uberModuleForeigns = [], uberModuleExports = [ ( Name "u", ObjectProp Nothing - ( Ref Nothing - ( Imported ( ModuleName "Golden.TestReturnTableField" ) ( Name "foreign" ) ) + ( ForeignImport Nothing + ( ModuleName "Golden.TestReturnTableField" ) "src/Golden/ReturnTableField/Test.purs" + [ ( Nothing, Name "u" ) ] ) ( PropName "u" ) ) diff --git a/test/ps/output/Golden.TestReturnTableField/golden.lua b/test/ps/output/Golden.TestReturnTableField/golden.lua index c983acb0..0d2d631f 100644 --- a/test/ps/output/Golden.TestReturnTableField/golden.lua +++ b/test/ps/output/Golden.TestReturnTableField/golden.lua @@ -1,2 +1 @@ -local Golden_TestReturnTableField_foreign = { u = nil } -return { u = Golden_TestReturnTableField_foreign.u } +return { u = nil } diff --git a/test/ps/output/Golden.UncurriedLift.Test/golden.ir b/test/ps/output/Golden.UncurriedLift.Test/golden.ir index 6281497a..45e27f85 100644 --- a/test/ps/output/Golden.UncurriedLift.Test/golden.ir +++ b/test/ps/output/Golden.UncurriedLift.Test/golden.ir @@ -13,16 +13,13 @@ UberModule ( ModuleName "Control.Monad.ST.Internal" ) ".spago/p/st/6d41fd264a05b9a089e79322b22b906597ea7c36/src/Control/Monad/ST/Internal.purs" [ ( Nothing, Name "pure_" ), ( Nothing, Name "run" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.UncurriedLift.Test/golden.lua b/test/ps/output/Golden.UncurriedLift.Test/golden.lua index 32cae0fb..04dff180 100644 --- a/test/ps/output/Golden.UncurriedLift.Test/golden.lua +++ b/test/ps/output/Golden.UncurriedLift.Test/golden.lua @@ -3,10 +3,7 @@ local Control_Monad_ST_Internal_foreign = { pure_ = function(a) return function() return a end end, run = function(f) return f() end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end local Golden_UncurriedLift_Test_logShow = function(a_S_0) return Effect_Console_log(Data_Show_foreign.showIntImpl(a_S_0)) end diff --git a/test/ps/output/Golden.Uncurry.Test/golden.ir b/test/ps/output/Golden.Uncurry.Test/golden.ir index 0f417171..ba0456c6 100644 --- a/test/ps/output/Golden.Uncurry.Test/golden.ir +++ b/test/ps/output/Golden.Uncurry.Test/golden.ir @@ -19,16 +19,13 @@ UberModule ( ModuleName "Data.Functor" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Functor.purs" [ ( Nothing, Name "arrayMap" ) ] ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.Uncurry.Test/golden.lua b/test/ps/output/Golden.Uncurry.Test/golden.lua index 470aa609..10b0bfde 100644 --- a/test/ps/output/Golden.Uncurry.Test/golden.lua +++ b/test/ps/output/Golden.Uncurry.Test/golden.lua @@ -21,10 +21,7 @@ local Data_Functor_foreign = { end end } -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end local Data_Show_showInt = { show = Data_Show_showIntImpl } local Data_Show_show = function(dict) return dict.show end local Effect_Console_logShow_S_w = function(dictShow, a) diff --git a/test/ps/output/Golden.UncurryCtor.Test/golden.ir b/test/ps/output/Golden.UncurryCtor.Test/golden.ir index ffb7e023..1aa965fc 100644 --- a/test/ps/output/Golden.UncurryCtor.Test/golden.ir +++ b/test/ps/output/Golden.UncurryCtor.Test/golden.ir @@ -13,22 +13,13 @@ UberModule ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Data.Functor", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Functor" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Functor.purs" - [ ( Nothing, Name "arrayMap" ) ] - ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName @@ -75,7 +66,10 @@ UberModule ( QName { qnameModuleName = ModuleName "Golden.UncurryCtor.Test", qnameName = Name "map" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Functor" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Functor" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Functor.purs" + [ ( Nothing, Name "arrayMap" ) ] + ) ( PropName "arrayMap" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.UncurryCtor.Test/golden.lua b/test/ps/output/Golden.UncurryCtor.Test/golden.lua index 3bb630b6..5288c7d7 100644 --- a/test/ps/output/Golden.UncurryCtor.Test/golden.lua +++ b/test/ps/output/Golden.UncurryCtor.Test/golden.lua @@ -10,20 +10,7 @@ local Data_Show_foreign = { end } local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Data_Functor_foreign = { - arrayMap = function(f) - return function(arr) - local l = #(arr) - local result = {} - for i = 1, l do result[i] = f(arr[i]) end - return result - end - end -} -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Effect_Console_log = function(s) return function() print(s) end end local Data_Show_showInt = { show = Data_Show_showIntImpl } local Data_Show_show = function(dict) return dict.show end local Effect_Console_logShow_S_w = function(dictShow, a) @@ -32,7 +19,14 @@ end local Golden_UncurryCtor_Test_logShow = function(logShow_S_p2_S_0) return Effect_Console_log(Data_Show_showIntImpl(logShow_S_p2_S_0)) end -local Golden_UncurryCtor_Test_map = Data_Functor_foreign.arrayMap +local Golden_UncurryCtor_Test_map = function(f) + return function(arr) + local l = #(arr) + local result = {} + for i = 1, l do result[i] = f(arr[i]) end + return result + end +end local Golden_UncurryCtor_Test_Origin = { "Golden.UncurryCtor.Test∷Shape.Origin" } diff --git a/test/ps/output/Golden.UncurryEffect.Test/golden.ir b/test/ps/output/Golden.UncurryEffect.Test/golden.ir index 44413658..664519ce 100644 --- a/test/ps/output/Golden.UncurryEffect.Test/golden.ir +++ b/test/ps/output/Golden.UncurryEffect.Test/golden.ir @@ -1,28 +1,22 @@ UberModule { uberModuleBindings = [ Standalone - ( QName - { qnameModuleName = ModuleName "Data.Show", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" - [ ( Nothing, Name "showIntImpl" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Data.Show", qnameName = Name "showIntImpl" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Data.Show" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Data.Show" ) ".spago/p/prelude/5718c84fdde6247749cb053e816df696c30fe691/src/Data/Show.purs" + [ ( Nothing, Name "showIntImpl" ) ] + ) ( PropName "showIntImpl" ) ), Standalone - ( QName - { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "foreign" - }, ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" - [ ( Nothing, Name "log" ) ] - ), Standalone ( QName { qnameModuleName = ModuleName "Effect.Console", qnameName = Name "log" }, ObjectProp Nothing - ( Ref Nothing ( Imported ( ModuleName "Effect.Console" ) ( Name "foreign" ) ) ) + ( ForeignImport Nothing + ( ModuleName "Effect.Console" ) ".spago/p/console/f82835a0b873aafe6bd7b14dd30cc150553d4ab9/src/Effect/Console.purs" + [ ( Nothing, Name "log" ) ] + ) ( PropName "log" ) ), Standalone ( QName diff --git a/test/ps/output/Golden.UncurryEffect.Test/golden.lua b/test/ps/output/Golden.UncurryEffect.Test/golden.lua index 30f20f43..d44e082a 100644 --- a/test/ps/output/Golden.UncurryEffect.Test/golden.lua +++ b/test/ps/output/Golden.UncurryEffect.Test/golden.lua @@ -1,10 +1,6 @@ local M = {} -local Data_Show_foreign = { showIntImpl = function(n) return tostring(n) end } -local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl -local Effect_Console_foreign = { - log = function(s) return function() print(s) end end -} -local Effect_Console_log = Effect_Console_foreign.log +local Data_Show_showIntImpl = function(n) return tostring(n) end +local Effect_Console_log = function(s) return function() print(s) end end local Golden_UncurryEffect_Test_tick_S_w = function(n) local _ = Effect_Console_log("tick")() return Effect_Console_log(Data_Show_showIntImpl(n))() diff --git a/test/ps/src/Golden/ForeignHeader/Test.lua b/test/ps/src/Golden/ForeignHeader/Test.lua new file mode 100644 index 00000000..0458bd40 --- /dev/null +++ b/test/ps/src/Golden/ForeignHeader/Test.lua @@ -0,0 +1,4 @@ +local prefix = "tag" +return { + tag = (prefix .. "ged") +} diff --git a/test/ps/src/Golden/ForeignHeader/Test.purs b/test/ps/src/Golden/ForeignHeader/Test.purs new file mode 100644 index 00000000..194fca5d --- /dev/null +++ b/test/ps/src/Golden/ForeignHeader/Test.purs @@ -0,0 +1,22 @@ +-- | Pins the header condition of the single-use foreign-import fold +-- | (#251). The import is read exactly once, from the right-hand side of +-- | the shared accessor `tag` — a once-evaluated position — so only the +-- | header statement in `Test.lua` holds the table hoisted: its effects +-- | run at a fixed point in module init, and folding the import into the +-- | accessor would move them. +-- | +-- | `Golden.ForeignAccessorDefault.Test` is the same shape over +-- | header-free sources, where the pair does collapse. +module Golden.ForeignHeader.Test where + +import Prelude + +import Effect (Effect) +import Effect.Console (log) + +foreign import tag :: String + +main :: Effect Unit +main = do + log tag + log tag