diff --git a/test/ps/golden/Golden/Issue37/Test.purs b/test/ps/golden/Golden/Issue37/Test.purs new file mode 100644 index 0000000..bd81f1a --- /dev/null +++ b/test/ps/golden/Golden/Issue37/Test.purs @@ -0,0 +1,20 @@ +module Golden.Issue37.Test where + +import Prelude +import Effect (Effect) + +baz :: Effect Unit +baz = bar (pure unit) + +bar :: forall f. Monad f => f Unit -> f Unit +bar f = do + f + _ <- pure [ foo f ] + pure unit + +foo :: forall f. Monad f => f Unit -> f Unit +foo fn1 = do + _ <- fn1 + fn1 + fn1 + fn1 diff --git a/test/ps/output/Golden.Issue37.Test/corefn.json b/test/ps/output/Golden.Issue37.Test/corefn.json new file mode 100644 index 0000000..baaff85 --- /dev/null +++ b/test/ps/output/Golden.Issue37.Test/corefn.json @@ -0,0 +1 @@ +{"builtWith":"0.15.15","comments":[],"decls":[{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"bindType":"NonRec","expression":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[18,6],"start":[18,3]}},"type":"Var","value":{"identifier":"discard","moduleName":["Control","Bind"]}},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[18,6],"start":[18,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"discardUnit","moduleName":["Control","Bind"]}},"type":"App"},"identifier":"discard"},{"annotation":{"meta":null,"sourceSpan":{"end":[15,45],"start":[15,1]}},"bindType":"NonRec","expression":{"annotation":{"meta":null,"sourceSpan":{"end":[15,45],"start":[15,1]}},"argument":"dictMonad","body":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"binds":[{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"bindType":"NonRec","expression":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[17,11],"start":[17,3]}},"expression":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"dictMonad","sourcePos":[0,0]}},"fieldName":"Bind1","type":"Accessor"},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[17,11],"start":[17,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"undefined","moduleName":["Prim"]}},"type":"App"},"identifier":"Bind1"},{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"bindType":"NonRec","expression":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[17,11],"start":[17,3]}},"type":"Var","value":{"identifier":"bind","moduleName":["Control","Bind"]}},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[17,11],"start":[17,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"Bind1","sourcePos":[0,0]}},"type":"App"},"identifier":"bind"},{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"bindType":"NonRec","expression":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"discard","moduleName":["Golden","Issue37","Test"]}},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[18,6],"start":[18,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"Bind1","sourcePos":[0,0]}},"type":"App"},"identifier":"discard1"}],"expression":{"annotation":{"meta":null,"sourceSpan":{"end":[15,45],"start":[15,1]}},"argument":"fn1","body":{"abstraction":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"bind","sourcePos":[0,0]}},"annotation":{"meta":null,"sourceSpan":{"end":[17,11],"start":[17,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[17,11],"start":[17,8]}},"type":"Var","value":{"identifier":"fn1","sourcePos":[16,1]}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[17,11],"start":[17,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[17,11],"start":[17,3]}},"argument":"$__unused","body":{"abstraction":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"discard1","sourcePos":[0,0]}},"annotation":{"meta":null,"sourceSpan":{"end":[18,6],"start":[18,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[18,6],"start":[18,3]}},"type":"Var","value":{"identifier":"fn1","sourcePos":[16,1]}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[18,6],"start":[18,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[18,6],"start":[18,3]}},"argument":"$__unused","body":{"abstraction":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"discard1","sourcePos":[0,0]}},"annotation":{"meta":null,"sourceSpan":{"end":[19,6],"start":[19,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[19,6],"start":[19,3]}},"type":"Var","value":{"identifier":"fn1","sourcePos":[16,1]}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[19,6],"start":[19,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[19,6],"start":[19,3]}},"argument":"$__unused","body":{"annotation":{"meta":null,"sourceSpan":{"end":[20,6],"start":[20,3]}},"type":"Var","value":{"identifier":"fn1","sourcePos":[16,1]}},"type":"Abs"},"type":"App"},"type":"Abs"},"type":"App"},"type":"Abs"},"type":"App"},"type":"Abs"},"type":"Let"},"type":"Abs"},"identifier":"foo"},{"annotation":{"meta":null,"sourceSpan":{"end":[9,45],"start":[9,1]}},"bindType":"NonRec","expression":{"annotation":{"meta":null,"sourceSpan":{"end":[9,45],"start":[9,1]}},"argument":"dictMonad","body":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"binds":[{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"bindType":"NonRec","expression":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[11,4],"start":[11,3]}},"expression":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"dictMonad","sourcePos":[0,0]}},"fieldName":"Bind1","type":"Accessor"},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[11,4],"start":[11,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"undefined","moduleName":["Prim"]}},"type":"App"},"identifier":"Bind1"},{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"bindType":"NonRec","expression":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"discard","moduleName":["Golden","Issue37","Test"]}},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[11,4],"start":[11,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"Bind1","sourcePos":[0,0]}},"type":"App"},"identifier":"discard1"},{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"bindType":"NonRec","expression":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[12,22],"start":[12,3]}},"type":"Var","value":{"identifier":"bind","moduleName":["Control","Bind"]}},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[12,22],"start":[12,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"Bind1","sourcePos":[0,0]}},"type":"App"},"identifier":"bind"},{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"bindType":"NonRec","expression":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[12,12],"start":[12,8]}},"type":"Var","value":{"identifier":"pure","moduleName":["Control","Applicative"]}},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[12,22],"start":[12,8]}},"argument":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[12,22],"start":[12,8]}},"expression":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"dictMonad","sourcePos":[0,0]}},"fieldName":"Applicative0","type":"Accessor"},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[12,22],"start":[12,8]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"undefined","moduleName":["Prim"]}},"type":"App"},"type":"App"},"identifier":"pure"},{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"bindType":"NonRec","expression":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[12,18],"start":[12,15]}},"type":"Var","value":{"identifier":"foo","moduleName":["Golden","Issue37","Test"]}},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[12,20],"start":[12,15]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"dictMonad","sourcePos":[0,0]}},"type":"App"},"identifier":"foo1"}],"expression":{"annotation":{"meta":null,"sourceSpan":{"end":[9,45],"start":[9,1]}},"argument":"f","body":{"abstraction":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"discard1","sourcePos":[0,0]}},"annotation":{"meta":null,"sourceSpan":{"end":[11,4],"start":[11,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[11,4],"start":[11,3]}},"type":"Var","value":{"identifier":"f","sourcePos":[10,1]}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[11,4],"start":[11,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[11,4],"start":[11,3]}},"argument":"$__unused","body":{"abstraction":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"bind","sourcePos":[0,0]}},"annotation":{"meta":null,"sourceSpan":{"end":[12,22],"start":[12,3]}},"argument":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"pure","sourcePos":[0,0]}},"annotation":{"meta":null,"sourceSpan":{"end":[12,22],"start":[12,8]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[12,22],"start":[12,13]}},"type":"Literal","value":{"literalType":"ArrayLiteral","value":[{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"foo1","sourcePos":[0,0]}},"annotation":{"meta":null,"sourceSpan":{"end":[12,20],"start":[12,15]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[12,20],"start":[12,19]}},"type":"Var","value":{"identifier":"f","sourcePos":[10,1]}},"type":"App"}]}},"type":"App"},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[12,22],"start":[12,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[12,22],"start":[12,3]}},"argument":"$__unused","body":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"pure","sourcePos":[0,0]}},"annotation":{"meta":null,"sourceSpan":{"end":[13,12],"start":[13,3]}},"argument":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[13,12],"start":[13,8]}},"type":"Var","value":{"identifier":"unit","moduleName":["Data","Unit"]}},"type":"App"},"type":"Abs"},"type":"App"},"type":"Abs"},"type":"App"},"type":"Abs"},"type":"Let"},"type":"Abs"},"identifier":"bar"},{"annotation":{"meta":null,"sourceSpan":{"end":[6,19],"start":[6,1]}},"bindType":"NonRec","expression":{"abstraction":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[7,10],"start":[7,7]}},"type":"Var","value":{"identifier":"bar","moduleName":["Golden","Issue37","Test"]}},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[7,22],"start":[7,7]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"monadEffect","moduleName":["Effect"]}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[7,22],"start":[7,7]}},"argument":{"abstraction":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[7,16],"start":[7,12]}},"type":"Var","value":{"identifier":"pure","moduleName":["Control","Applicative"]}},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[7,21],"start":[7,12]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"applicativeEffect","moduleName":["Effect"]}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[7,21],"start":[7,12]}},"argument":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[7,21],"start":[7,17]}},"type":"Var","value":{"identifier":"unit","moduleName":["Data","Unit"]}},"type":"App"},"type":"App"},"identifier":"baz"}],"exports":["baz","bar","foo"],"foreign":[],"imports":[{"annotation":{"meta":null,"sourceSpan":{"end":[20,6],"start":[1,1]}},"moduleName":["Control","Applicative"]},{"annotation":{"meta":null,"sourceSpan":{"end":[20,6],"start":[1,1]}},"moduleName":["Control","Bind"]},{"annotation":{"meta":null,"sourceSpan":{"end":[20,6],"start":[1,1]}},"moduleName":["Data","Unit"]},{"annotation":{"meta":null,"sourceSpan":{"end":[20,6],"start":[1,1]}},"moduleName":["Effect"]},{"annotation":{"meta":null,"sourceSpan":{"end":[20,6],"start":[1,1]}},"moduleName":["Golden","Issue37","Test"]},{"annotation":{"meta":null,"sourceSpan":{"end":[3,15],"start":[3,1]}},"moduleName":["Prelude"]},{"annotation":{"meta":null,"sourceSpan":{"end":[20,6],"start":[1,1]}},"moduleName":["Prim"]}],"moduleName":["Golden","Issue37","Test"],"modulePath":"golden/Golden/Issue37/Test.purs","reExports":{},"sourceSpan":{"end":[20,6],"start":[1,1]}} \ No newline at end of file diff --git a/test/ps/output/Golden.Issue37.Test/golden.ir b/test/ps/output/Golden.Issue37.Test/golden.ir new file mode 100644 index 0000000..d2324b5 --- /dev/null +++ b/test/ps/output/Golden.Issue37.Test/golden.ir @@ -0,0 +1,384 @@ +UberModule + { uberModuleBindings = + [ Standalone + ( QName + { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" + }, ForeignImport Nothing + ( ModuleName "Data.Unit" ) ".spago/prelude/v7.2.0/src/Data/Unit.purs" + [ ( Just Always, Name "unit" ) ] + ), Standalone + ( QName + { qnameModuleName = ModuleName "Effect", qnameName = Name "foreign" + }, ForeignImport Nothing + ( ModuleName "Effect" ) ".spago/effect/v4.1.0/src/Effect.purs" + [ ( Nothing, Name "pureE" ), ( Nothing, Name "bindE" ) ] + ), Standalone + ( QName + { qnameModuleName = ModuleName "Control.Applicative", qnameName = Name "pure" + }, Abs Nothing + ( ParamNamed Nothing ( Name "dict" ) ) + ( ObjectProp Nothing ( Ref Nothing ( Local ( Name "dict" ) ) 0 ) ( PropName "pure" ) ) + ), Standalone + ( QName + { qnameModuleName = ModuleName "Control.Bind", qnameName = Name "bind" }, Abs Nothing + ( ParamNamed Nothing ( Name "dict" ) ) + ( ObjectProp Nothing ( Ref Nothing ( Local ( Name "dict" ) ) 0 ) ( PropName "bind" ) ) + ), RecursiveGroup + ( + ( QName + { qnameModuleName = ModuleName "Effect", qnameName = Name "monadEffect" + }, LiteralObject Nothing + [ + ( PropName "Applicative0", Abs Nothing ( ParamUnused Nothing ) + ( Ref Nothing ( Imported ( ModuleName "Effect" ) ( Name "applicativeEffect" ) ) 0 ) + ), + ( PropName "Bind1", Abs Nothing ( ParamUnused Nothing ) + ( Ref Nothing ( Imported ( ModuleName "Effect" ) ( Name "bindEffect" ) ) 0 ) + ) + ] + ) :| + [ + ( QName + { qnameModuleName = ModuleName "Effect", qnameName = Name "bindEffect" + }, LiteralObject Nothing + [ + ( PropName "bind", ObjectProp ( Just Always ) + ( Ref Nothing ( Imported ( ModuleName "Effect" ) ( Name "foreign" ) ) 0 ) + ( PropName "bindE" ) + ), + ( PropName "Apply0", Abs Nothing ( ParamUnused Nothing ) + ( App Nothing + ( Ref Nothing + ( Imported ( ModuleName "Effect" ) ( Name "Lazy_applyEffect" ) ) 0 + ) + ( LiteralInt Nothing 0 ) + ) + ) + ] + ), + ( QName + { qnameModuleName = ModuleName "Effect", qnameName = Name "applicativeEffect" + }, LiteralObject Nothing + [ + ( PropName "pure", ObjectProp ( Just Always ) + ( Ref Nothing ( Imported ( ModuleName "Effect" ) ( Name "foreign" ) ) 0 ) + ( PropName "pureE" ) + ), + ( PropName "Apply0", Abs Nothing ( ParamUnused Nothing ) + ( App Nothing + ( Ref Nothing + ( Imported ( ModuleName "Effect" ) ( Name "Lazy_applyEffect" ) ) 0 + ) + ( LiteralInt Nothing 0 ) + ) + ) + ] + ), + ( QName + { qnameModuleName = ModuleName "Effect", qnameName = Name "Lazy_functorEffect" + }, App Nothing + ( App Nothing + ( Ref Nothing ( Local ( Name "PSLUA_runtime_lazy" ) ) 0 ) + ( LiteralString Nothing "functorEffect" ) + ) + ( Abs Nothing ( ParamUnused Nothing ) + ( LiteralObject Nothing + [ + ( PropName "map", Abs Nothing + ( ParamNamed Nothing ( Name "f" ) ) + ( App Nothing + ( ObjectProp Nothing + ( App Nothing + ( ObjectProp Nothing + ( Ref Nothing + ( Imported ( ModuleName "Effect" ) ( Name "applicativeEffect" ) ) 0 + ) + ( PropName "Apply0" ) + ) + ( Ref Nothing ( Imported ( ModuleName "Prim" ) ( Name "undefined" ) ) 0 ) + ) + ( PropName "apply" ) + ) + ( App Nothing + ( App Nothing + ( Ref Nothing + ( Imported ( ModuleName "Control.Applicative" ) ( Name "pure" ) ) 0 + ) + ( Ref Nothing + ( Imported ( ModuleName "Effect" ) ( Name "applicativeEffect" ) ) 0 + ) + ) + ( Ref Nothing ( Local ( Name "f" ) ) 0 ) + ) + ) + ) + ] + ) + ) + ), + ( QName + { qnameModuleName = ModuleName "Effect", qnameName = Name "Lazy_applyEffect" + }, App Nothing + ( App Nothing + ( Ref Nothing ( Local ( Name "PSLUA_runtime_lazy" ) ) 0 ) + ( LiteralString Nothing "applyEffect" ) + ) + ( Abs Nothing ( ParamUnused Nothing ) + ( LiteralObject Nothing + [ + ( PropName "apply", Let Nothing + ( Standalone + ( Nothing, Name "bind", App Nothing + ( Ref Nothing + ( Imported ( ModuleName "Control.Bind" ) ( Name "bind" ) ) 0 + ) + ( App Nothing + ( ObjectProp Nothing + ( Ref Nothing + ( Imported ( ModuleName "Effect" ) ( Name "monadEffect" ) ) 0 + ) + ( PropName "Bind1" ) + ) + ( Ref Nothing ( Imported ( ModuleName "Prim" ) ( Name "undefined" ) ) 0 ) + ) + ) :| [] + ) + ( Abs Nothing + ( ParamNamed Nothing ( Name "f" ) ) + ( Abs Nothing + ( ParamNamed Nothing ( Name "a" ) ) + ( App Nothing + ( App Nothing + ( Ref Nothing ( Local ( Name "bind" ) ) 0 ) + ( Ref Nothing ( Local ( Name "f" ) ) 0 ) + ) + ( Abs Nothing + ( ParamNamed Nothing ( Name "f'" ) ) + ( App Nothing + ( App Nothing + ( Ref Nothing ( Local ( Name "bind" ) ) 0 ) + ( Ref Nothing ( Local ( Name "a" ) ) 0 ) + ) + ( Abs Nothing + ( ParamNamed Nothing ( Name "a'" ) ) + ( App Nothing + ( App Nothing + ( Ref Nothing + ( Imported + ( ModuleName "Control.Applicative" ) + ( Name "pure" ) + ) 0 + ) + ( App Nothing + ( ObjectProp Nothing + ( Ref Nothing + ( Imported + ( ModuleName "Effect" ) + ( Name "monadEffect" ) + ) 0 + ) + ( PropName "Applicative0" ) + ) + ( Ref Nothing + ( Imported ( ModuleName "Prim" ) ( Name "undefined" ) ) 0 + ) + ) + ) + ( App Nothing + ( Ref Nothing ( Local ( Name "f'" ) ) 0 ) + ( Ref Nothing ( Local ( Name "a'" ) ) 0 ) + ) + ) + ) + ) + ) + ) + ) + ) + ), + ( PropName "Functor0", Abs Nothing ( ParamUnused Nothing ) + ( App Nothing + ( Ref Nothing + ( Imported ( ModuleName "Effect" ) ( Name "Lazy_functorEffect" ) ) 0 + ) + ( LiteralInt Nothing 0 ) + ) + ) + ] + ) + ) + ) + ] + ), Standalone + ( QName + { qnameModuleName = ModuleName "Golden.Issue37.Test", qnameName = Name "discard" + }, ObjectProp Nothing + ( LiteralObject Nothing + [ + ( PropName "discard", Ref Nothing + ( Imported ( ModuleName "Control.Bind" ) ( Name "bind" ) ) 0 + ) + ] + ) + ( PropName "discard" ) + ), Standalone + ( QName + { qnameModuleName = ModuleName "Golden.Issue37.Test", qnameName = Name "foo" }, Abs Nothing + ( ParamNamed Nothing ( Name "dictMonad" ) ) + ( Let Nothing + ( Standalone + ( Nothing, Name "Bind1", App Nothing + ( ObjectProp Nothing + ( Ref Nothing ( Local ( Name "dictMonad" ) ) 0 ) + ( PropName "Bind1" ) + ) + ( Ref Nothing ( Imported ( ModuleName "Prim" ) ( Name "undefined" ) ) 0 ) + ) :| + [ Standalone + ( Nothing, Name "discard1", App Nothing + ( Ref Nothing + ( Imported ( ModuleName "Golden.Issue37.Test" ) ( Name "discard" ) ) 0 + ) + ( Ref Nothing ( Local ( Name "Bind1" ) ) 0 ) + ) + ] + ) + ( Abs Nothing + ( ParamNamed Nothing ( Name "fn1" ) ) + ( App Nothing + ( App Nothing + ( App Nothing + ( Ref Nothing ( Imported ( ModuleName "Control.Bind" ) ( Name "bind" ) ) 0 ) + ( App Nothing + ( ObjectProp Nothing + ( Ref Nothing ( Local ( Name "dictMonad" ) ) 0 ) + ( PropName "Bind1" ) + ) + ( Ref Nothing ( Imported ( ModuleName "Prim" ) ( Name "undefined" ) ) 0 ) + ) + ) + ( Ref Nothing ( Local ( Name "fn1" ) ) 0 ) + ) + ( Abs Nothing ( ParamUnused Nothing ) + ( App Nothing + ( App Nothing + ( Ref Nothing ( Local ( Name "discard1" ) ) 0 ) + ( Ref Nothing ( Local ( Name "fn1" ) ) 0 ) + ) + ( Abs Nothing ( ParamUnused Nothing ) + ( App Nothing + ( App Nothing + ( Ref Nothing ( Local ( Name "discard1" ) ) 0 ) + ( Ref Nothing ( Local ( Name "fn1" ) ) 0 ) + ) + ( Abs Nothing ( ParamUnused Nothing ) + ( Ref Nothing ( Local ( Name "fn1" ) ) 0 ) + ) + ) + ) + ) + ) + ) + ) + ) + ), Standalone + ( QName + { qnameModuleName = ModuleName "Golden.Issue37.Test", qnameName = Name "bar" }, Abs Nothing + ( ParamNamed Nothing ( Name "dictMonad" ) ) + ( Let Nothing + ( Standalone + ( Nothing, Name "Bind1", App Nothing + ( ObjectProp Nothing + ( Ref Nothing ( Local ( Name "dictMonad" ) ) 0 ) + ( PropName "Bind1" ) + ) + ( Ref Nothing ( Imported ( ModuleName "Prim" ) ( Name "undefined" ) ) 0 ) + ) :| + [ Standalone + ( Nothing, Name "pure", App Nothing + ( Ref Nothing ( Imported ( ModuleName "Control.Applicative" ) ( Name "pure" ) ) 0 ) + ( App Nothing + ( ObjectProp Nothing + ( Ref Nothing ( Local ( Name "dictMonad" ) ) 0 ) + ( PropName "Applicative0" ) + ) + ( Ref Nothing ( Imported ( ModuleName "Prim" ) ( Name "undefined" ) ) 0 ) + ) + ) + ] + ) + ( Abs Nothing + ( ParamNamed Nothing ( Name "f" ) ) + ( App Nothing + ( App Nothing + ( App Nothing + ( Ref Nothing + ( Imported ( ModuleName "Golden.Issue37.Test" ) ( Name "discard" ) ) 0 + ) + ( Ref Nothing ( Local ( Name "Bind1" ) ) 0 ) + ) + ( Ref Nothing ( Local ( Name "f" ) ) 0 ) + ) + ( Abs Nothing ( ParamUnused Nothing ) + ( App Nothing + ( App Nothing + ( App Nothing + ( Ref Nothing ( Imported ( ModuleName "Control.Bind" ) ( Name "bind" ) ) 0 ) + ( Ref Nothing ( Local ( Name "Bind1" ) ) 0 ) + ) + ( App Nothing + ( Ref Nothing ( Local ( Name "pure" ) ) 0 ) + ( LiteralArray Nothing + [ App Nothing + ( App Nothing + ( Ref Nothing + ( Imported ( ModuleName "Golden.Issue37.Test" ) ( Name "foo" ) ) 0 + ) + ( Ref Nothing ( Local ( Name "dictMonad" ) ) 0 ) + ) + ( Ref Nothing ( Local ( Name "f" ) ) 0 ) + ] + ) + ) + ) + ( Abs Nothing ( ParamUnused Nothing ) + ( App Nothing + ( Ref Nothing ( Local ( Name "pure" ) ) 0 ) + ( ObjectProp ( Just Always ) + ( Ref Nothing + ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) 0 + ) + ( PropName "unit" ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ], uberModuleForeigns = [], uberModuleExports = + [ + ( Name "baz", App Nothing + ( App Nothing + ( Ref Nothing ( Imported ( ModuleName "Golden.Issue37.Test" ) ( Name "bar" ) ) 0 ) + ( Ref Nothing ( Imported ( ModuleName "Effect" ) ( Name "monadEffect" ) ) 0 ) + ) + ( App Nothing + ( App Nothing + ( Ref Nothing ( Imported ( ModuleName "Control.Applicative" ) ( Name "pure" ) ) 0 ) + ( Ref Nothing ( Imported ( ModuleName "Effect" ) ( Name "applicativeEffect" ) ) 0 ) + ) + ( ObjectProp ( Just Always ) + ( Ref Nothing ( Imported ( ModuleName "Data.Unit" ) ( Name "foreign" ) ) 0 ) + ( PropName "unit" ) + ) + ) + ), + ( Name "bar", Ref Nothing + ( Imported ( ModuleName "Golden.Issue37.Test" ) ( Name "bar" ) ) 0 + ), + ( Name "foo", Ref Nothing ( Imported ( ModuleName "Golden.Issue37.Test" ) ( Name "foo" ) ) 0 ) + ] + } \ No newline at end of file diff --git a/test/ps/output/Golden.Issue37.Test/golden.lua b/test/ps/output/Golden.Issue37.Test/golden.lua new file mode 100644 index 0000000..d255ff6 --- /dev/null +++ b/test/ps/output/Golden.Issue37.Test/golden.lua @@ -0,0 +1,102 @@ +local function PSLUA_runtime_lazy(name) + return function(init) + return function() + local state = 0 + local val = nil + if state == 2 then + return val + else + if state == 1 then + return error(name .. " was needed before it finished initializing") + else + state = 1 + val = init() + state = 2 + return val + end + end + end + end +end +local M = {} +M.Data_Unit_foreign = { unit = {} } +M.Effect_foreign = { + pureE = function(a) + return function() + return a + end + end, + bindE = function(a) + return function(f) + return function() + return f(a())() + end + end + end +} +M.Control_Applicative_pure = function(dict) return dict.pure end +M.Control_Bind_bind = function(dict) return dict.bind end +M.Effect_monadEffect = { + Applicative0 = function() return M.Effect_applicativeEffect end, + Bind1 = function() return M.Effect_bindEffect end +} +M.Effect_bindEffect = { + bind = M.Effect_foreign.bindE, + Apply0 = function() return M.Effect_Lazy_applyEffect(0) end +} +M.Effect_applicativeEffect = { + pure = M.Effect_foreign.pureE, + Apply0 = function() return M.Effect_Lazy_applyEffect(0) end +} +M.Effect_Lazy_functorEffect = PSLUA_runtime_lazy("functorEffect")(function() + return { + map = function(f) + return (M.Effect_applicativeEffect.Apply0()).apply(M.Control_Applicative_pure(M.Effect_applicativeEffect)(f)) + end + } +end) +M.Effect_Lazy_applyEffect = PSLUA_runtime_lazy("applyEffect")(function() + return { + apply = (function() + return function(f) + local bind = M.Control_Bind_bind(M.Effect_monadEffect.Bind1()) + return function(a) + return bind(f)(function(fPrime) + return bind(a)(function(aPrime) + return M.Control_Applicative_pure(M.Effect_monadEffect.Applicative0())(fPrime(aPrime)) + end) + end) + end + end + end)(), + Functor0 = function() return M.Effect_Lazy_functorEffect(0) end + } +end) +M.Golden_Issue37_Test_discard = M.Control_Bind_bind +M.Golden_Issue37_Test_foo = function(dictMonad) + return function(fn1) + local Bind1 = dictMonad.Bind1() + local discard1 = M.Golden_Issue37_Test_discard(Bind1) + return M.Control_Bind_bind(dictMonad.Bind1())(fn1)(function() + return discard1(fn1)(function() + return discard1(fn1)(function() return fn1 end) + end) + end) + end +end +M.Golden_Issue37_Test_bar = function(dictMonad) + return function(f) + local Bind1 = dictMonad.Bind1() + local pure = M.Control_Applicative_pure(dictMonad.Applicative0()) + return M.Golden_Issue37_Test_discard(Bind1)(f)(function() + return M.Control_Bind_bind(Bind1)(pure({ + [1] = M.Golden_Issue37_Test_foo(dictMonad)(f) + }))(function() return pure(M.Data_Unit_foreign.unit) end) + end) + end +end +return { + baz = M.Golden_Issue37_Test_bar(M.Effect_monadEffect)(M.Control_Applicative_pure(M.Effect_applicativeEffect)(M.Data_Unit_foreign.unit)), + bar = M.Golden_Issue37_Test_bar, + foo = M.Golden_Issue37_Test_foo +}