Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/ps/golden/Golden/MaybeChain/Test.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Golden.MaybeChain.Test where

import Prelude

import Data.Maybe (Maybe(..), maybe)
import Effect (Effect)
import Effect.Console (logShow)

-- Repro for issue #30: nested maybe/map chains used to make the
-- (since removed) currying optimizer crash with
-- "Impossible subexpressions: IfThenElse".
main :: Effect Unit
main = do
logShow $ maybe 0 identity (maybe Nothing Just (map (\x -> x) Nothing))
logShow $ maybe 0 identity (maybe Nothing Just (map (\x -> x) (Just 42)))
14 changes: 14 additions & 0 deletions test/ps/golden/Golden/MaybeChainModule/Test.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Golden.MaybeChainModule.Test where

import Prelude

import Data.Maybe (Maybe(..), maybe)

-- Same expressions as Golden.MaybeChain.Test, but without `main` and
-- without an eval golden, so the golden suite compiles this module in
-- LinkAsModule mode: the mode in which issue #30 reported the crash.
chainedNothing :: Int
chainedNothing = maybe 0 identity (maybe Nothing Just (map (\x -> x) Nothing))

chainedJust :: Int
chainedJust = maybe 0 identity (maybe Nothing Just (map (\x -> x) (Just 42)))
26 changes: 26 additions & 0 deletions test/ps/golden/Golden/ProfunctorDictLens/Test.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module Golden.ProfunctorDictLens.Test where

import Prelude

import Data.Newtype (class Newtype, unwrap)
import Data.Profunctor (class Profunctor, dimap)
import Data.Profunctor (wrapIso) as Profunctor
import Effect (Effect)
import Effect.Console (logShow)

newtype Wrapped = Wrapped Int

derive instance newtypeWrapped :: Newtype Wrapped _

-- Same shape as Data.Lens._Newtype from issue #28: a binding whose body
-- is an application of a dict-consuming function, abstracted over the
-- Profunctor dictionary. Used twice in main so that the used-once
-- inliner cannot mask a lost dictionary lambda.
_Wrapped :: forall p. Profunctor p => p Int Int -> p Wrapped Wrapped
_Wrapped = dimap unwrap Wrapped

main :: Effect Unit
main = do
logShow $ unwrap (_Wrapped (_ + 1) (Wrapped 10))
logShow $ unwrap (_Wrapped (_ * 2) (Wrapped 10))
logShow $ unwrap (Profunctor.wrapIso Wrapped (_ - 5) (Wrapped 10))
1 change: 1 addition & 0 deletions test/ps/output/Golden.MaybeChain.Test/corefn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"builtWith":"0.15.16","comments":[],"decls":[{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"bindType":"NonRec","expression":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[14,10],"start":[14,3]}},"type":"Var","value":{"identifier":"logShow","moduleName":["Effect","Console"]}},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[14,10],"start":[14,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"showInt","moduleName":["Data","Show"]}},"type":"App"},"identifier":"logShow"},{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"bindType":"NonRec","expression":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[14,29],"start":[14,21]}},"type":"Var","value":{"identifier":"identity","moduleName":["Control","Category"]}},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[14,29],"start":[14,21]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"categoryFn","moduleName":["Control","Category"]}},"type":"App"},"identifier":"identity"},{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"bindType":"NonRec","expression":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[14,54],"start":[14,51]}},"type":"Var","value":{"identifier":"map","moduleName":["Data","Functor"]}},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[14,64],"start":[14,51]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"functorMaybe","moduleName":["Data","Maybe"]}},"type":"App"},"identifier":"map"},{"annotation":{"meta":null,"sourceSpan":{"end":[12,20],"start":[12,1]}},"bindType":"NonRec","expression":{"abstraction":{"abstraction":{"abstraction":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[14,74],"start":[14,3]}},"type":"Var","value":{"identifier":"discard","moduleName":["Control","Bind"]}},"annotation":{"meta":{"metaType":"IsSyntheticApp"},"sourceSpan":{"end":[14,74],"start":[14,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":[14,74],"start":[14,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":[14,74],"start":[14,3]}},"argument":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"logShow","moduleName":["Golden","MaybeChain","Test"]}},"annotation":{"meta":null,"sourceSpan":{"end":[14,74],"start":[14,3]}},"argument":{"abstraction":{"abstraction":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[14,18],"start":[14,13]}},"type":"Var","value":{"identifier":"maybe","moduleName":["Data","Maybe"]}},"annotation":{"meta":null,"sourceSpan":{"end":[14,20],"start":[14,13]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[14,20],"start":[14,19]}},"type":"Literal","value":{"literalType":"IntLiteral","value":0}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[14,29],"start":[14,13]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"identity","moduleName":["Golden","MaybeChain","Test"]}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[14,74],"start":[14,13]}},"argument":{"abstraction":{"abstraction":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[14,36],"start":[14,31]}},"type":"Var","value":{"identifier":"maybe","moduleName":["Data","Maybe"]}},"annotation":{"meta":null,"sourceSpan":{"end":[14,44],"start":[14,31]}},"argument":{"annotation":{"meta":{"constructorType":"SumType","identifiers":[],"metaType":"IsConstructor"},"sourceSpan":{"end":[14,44],"start":[14,37]}},"type":"Var","value":{"identifier":"Nothing","moduleName":["Data","Maybe"]}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[14,49],"start":[14,31]}},"argument":{"annotation":{"meta":{"constructorType":"SumType","identifiers":["value0"],"metaType":"IsConstructor"},"sourceSpan":{"end":[14,49],"start":[14,45]}},"type":"Var","value":{"identifier":"Just","moduleName":["Data","Maybe"]}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[14,73],"start":[14,31]}},"argument":{"abstraction":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"map","moduleName":["Golden","MaybeChain","Test"]}},"annotation":{"meta":null,"sourceSpan":{"end":[14,64],"start":[14,51]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[14,63],"start":[14,56]}},"argument":"x","body":{"annotation":{"meta":null,"sourceSpan":{"end":[14,63],"start":[14,62]}},"type":"Var","value":{"identifier":"x","sourcePos":[14,57]}},"type":"Abs"},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[14,72],"start":[14,51]}},"argument":{"annotation":{"meta":{"constructorType":"SumType","identifiers":[],"metaType":"IsConstructor"},"sourceSpan":{"end":[14,72],"start":[14,65]}},"type":"Var","value":{"identifier":"Nothing","moduleName":["Data","Maybe"]}},"type":"App"},"type":"App"},"type":"App"},"type":"App"},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[14,74],"start":[14,3]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[14,74],"start":[14,3]}},"argument":"$__unused","body":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"logShow","moduleName":["Golden","MaybeChain","Test"]}},"annotation":{"meta":null,"sourceSpan":{"end":[15,76],"start":[15,3]}},"argument":{"abstraction":{"abstraction":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[15,18],"start":[15,13]}},"type":"Var","value":{"identifier":"maybe","moduleName":["Data","Maybe"]}},"annotation":{"meta":null,"sourceSpan":{"end":[15,20],"start":[15,13]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[15,20],"start":[15,19]}},"type":"Literal","value":{"literalType":"IntLiteral","value":0}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[15,29],"start":[15,13]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"identity","moduleName":["Golden","MaybeChain","Test"]}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[15,76],"start":[15,13]}},"argument":{"abstraction":{"abstraction":{"abstraction":{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[15,36],"start":[15,31]}},"type":"Var","value":{"identifier":"maybe","moduleName":["Data","Maybe"]}},"annotation":{"meta":null,"sourceSpan":{"end":[15,44],"start":[15,31]}},"argument":{"annotation":{"meta":{"constructorType":"SumType","identifiers":[],"metaType":"IsConstructor"},"sourceSpan":{"end":[15,44],"start":[15,37]}},"type":"Var","value":{"identifier":"Nothing","moduleName":["Data","Maybe"]}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[15,49],"start":[15,31]}},"argument":{"annotation":{"meta":{"constructorType":"SumType","identifiers":["value0"],"metaType":"IsConstructor"},"sourceSpan":{"end":[15,49],"start":[15,45]}},"type":"Var","value":{"identifier":"Just","moduleName":["Data","Maybe"]}},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[15,75],"start":[15,31]}},"argument":{"abstraction":{"abstraction":{"annotation":{"meta":null,"sourceSpan":{"end":[0,0],"start":[0,0]}},"type":"Var","value":{"identifier":"map","moduleName":["Golden","MaybeChain","Test"]}},"annotation":{"meta":null,"sourceSpan":{"end":[15,64],"start":[15,51]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[15,63],"start":[15,56]}},"argument":"x","body":{"annotation":{"meta":null,"sourceSpan":{"end":[15,63],"start":[15,62]}},"type":"Var","value":{"identifier":"x","sourcePos":[15,57]}},"type":"Abs"},"type":"App"},"annotation":{"meta":null,"sourceSpan":{"end":[15,74],"start":[15,51]}},"argument":{"abstraction":{"annotation":{"meta":{"constructorType":"SumType","identifiers":["value0"],"metaType":"IsConstructor"},"sourceSpan":{"end":[15,70],"start":[15,66]}},"type":"Var","value":{"identifier":"Just","moduleName":["Data","Maybe"]}},"annotation":{"meta":null,"sourceSpan":{"end":[15,73],"start":[15,66]}},"argument":{"annotation":{"meta":null,"sourceSpan":{"end":[15,73],"start":[15,71]}},"type":"Literal","value":{"literalType":"IntLiteral","value":42}},"type":"App"},"type":"App"},"type":"App"},"type":"App"},"type":"App"},"type":"Abs"},"type":"App"},"identifier":"main"}],"exports":["main"],"foreign":[],"imports":[{"annotation":{"meta":null,"sourceSpan":{"end":[15,76],"start":[1,1]}},"moduleName":["Control","Bind"]},{"annotation":{"meta":null,"sourceSpan":{"end":[15,76],"start":[1,1]}},"moduleName":["Control","Category"]},{"annotation":{"meta":null,"sourceSpan":{"end":[15,76],"start":[1,1]}},"moduleName":["Data","Function"]},{"annotation":{"meta":null,"sourceSpan":{"end":[15,76],"start":[1,1]}},"moduleName":["Data","Functor"]},{"annotation":{"meta":null,"sourceSpan":{"end":[15,76],"start":[1,1]}},"moduleName":["Data","Maybe"]},{"annotation":{"meta":null,"sourceSpan":{"end":[15,76],"start":[1,1]}},"moduleName":["Data","Show"]},{"annotation":{"meta":null,"sourceSpan":{"end":[15,76],"start":[1,1]}},"moduleName":["Effect"]},{"annotation":{"meta":null,"sourceSpan":{"end":[15,76],"start":[1,1]}},"moduleName":["Effect","Console"]},{"annotation":{"meta":null,"sourceSpan":{"end":[3,15],"start":[3,1]}},"moduleName":["Prelude"]},{"annotation":{"meta":null,"sourceSpan":{"end":[15,76],"start":[1,1]}},"moduleName":["Prim"]}],"moduleName":["Golden","MaybeChain","Test"],"modulePath":"golden/Golden/MaybeChain/Test.purs","reExports":{},"sourceSpan":{"end":[15,76],"start":[1,1]}}
1 change: 1 addition & 0 deletions test/ps/output/Golden.MaybeChain.Test/eval/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
actual.txt
2 changes: 2 additions & 0 deletions test/ps/output/Golden.MaybeChain.Test/eval/golden.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0
42
Loading
Loading