git.iko.soy/rowtype-yoga/purescm
on bytevector help sign in
Upgrade to package set 41.2.0 (#155)

--------- Co-authored-by: Jordan Martinez <jordanalex.martinez@protonmail.com>

commit95d8a1c949481bfc3a13b3e86ca35212253316a6 authorFabrizio Ferrai <fabrizio.ferrai@gmail.com> dateTue 19 Sep 2023, 15:43 (3 years ago) parenta679bbf
6 files changed+122−84
flake.nix+1−1 spago.yaml+66−12 src/Main.purs+16−17 src/PureScript/Backend/Chez/Builder.purs+1−1 test/Main.purs+12−14 test/Utils.purs+26−39
flake.nix+1−1
@@ -19,7 +19,7 @@
1919 };
2020
2121 outputs = { self, nixpkgs, flake-utils, easy-purescript-nix, ... }:
22− let supportedSystems = [ "x86_64-linux" "x86_64-darwin" ];
22+ let supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
2323 in flake-utils.lib.eachSystem supportedSystems (system:
2424 let
2525 pkgs = import nixpkgs { inherit system; };
spago.yaml+66−12
@@ -33,7 +33,6 @@ package:
3333 - node-child-process
3434 - node-execa
3535 - node-fs
36− - node-fs-aff
3736 - node-glob-basic
3837 - node-path
3938 - node-process
@@ -44,8 +43,34 @@ package:
4443 - refs
4544workspace:
4645 package_set:
47− registry: 20.0.1
46+ registry: 41.2.0
4847 extra_packages:
48+ dodo-printer:
49+ git: https://github.com/natefaubion/purescript-dodo-printer.git
50+ ref: 831c5c963a57ca4bfd62f96335267d7d0785851d
51+ dependencies:
52+ - aff
53+ - ansi
54+ - arrays
55+ - avar
56+ - console
57+ - control
58+ - effect
59+ - either
60+ - exceptions
61+ - foldable-traversable
62+ - integers
63+ - lists
64+ - maybe
65+ - minibench
66+ - newtype
67+ - parallel
68+ - partial
69+ - posix-types
70+ - prelude
71+ - safe-coerce
72+ - strings
73+ - tuples
4974 backend-optimizer:
5075 git: https://github.com/aristanetworks/purescript-backend-optimizer
5176 ref: 9de6bd8a00d31e51502a062d10bbddf53a401039
@@ -53,12 +78,12 @@ workspace:
5378 - aff
5479 - ansi
5580 - argonaut
56− - argonaut-codecs
5781 - argparse-basic
5882 - arrays
5983 - bifunctors
6084 - console
6185 - control
86+ - datetime
6287 - debug
6388 - dodo-printer
6489 - effect
@@ -73,25 +98,54 @@ workspace:
7398 - lists
7499 - maybe
75100 - newtype
76− - node-buffer
77− - node-child-process
78− - node-fs
79− - node-fs-aff
80− - node-glob-basic
81− - node-path
82− - node-process
83− - node-streams
101+ - now
102+ - numbers
84103 - ordered-collections
104+ - orders
85105 - parallel
86106 - partial
87107 - posix-types
88108 - prelude
89109 - refs
90110 - safe-coerce
111+ - st
91112 - strings
92113 - transformers
93114 - tuples
94115 - unsafe-coerce
116+ language-cst-parser:
117+ git: https://github.com/natefaubion/purescript-language-cst-parser.git
118+ ref: bf5623e08e1f43f923d4ff3c29cafbda25128768
119+ dependencies:
120+ - arrays
121+ - console
122+ - const
123+ - control
124+ - effect
125+ - either
126+ - enums
127+ - foldable-traversable
128+ - free
129+ - functions
130+ - functors
131+ - identity
132+ - integers
133+ - lazy
134+ - lists
135+ - maybe
136+ - newtype
137+ - node-process
138+ - numbers
139+ - ordered-collections
140+ - partial
141+ - prelude
142+ - st
143+ - strings
144+ - transformers
145+ - tuples
146+ - typelevel-prelude
147+ - unfoldable
148+ - unsafe-coerce
95149 node-glob-basic:
96150 git: https://github.com/natefaubion/purescript-node-glob-basic.git
97151 ref: v1.2.2
@@ -101,7 +155,7 @@ workspace:
101155 - effect
102156 - lists
103157 - maybe
104− - node-fs-aff
158+ - node-fs
105159 - node-path
106160 - node-process
107161 - ordered-collections
src/Main.purs+16−17
@@ -6,7 +6,7 @@ import ArgParse.Basic (ArgParser)
66import ArgParse.Basic as ArgParser
77import Data.Array as Array
88import Data.Either (Either(..), isRight)
9−import Data.Maybe (Maybe, fromMaybe)
9+import Data.Maybe (Maybe(..), fromMaybe)
1010import Data.Monoid (power)
1111import Data.Newtype (unwrap)
1212import Data.Set as Set
@@ -21,12 +21,13 @@ import Effect.Class (liftEffect)
2121import Effect.Class.Console as Console
2222import Effect.Exception (message)
2323import Node.Encoding (Encoding(..))
24+import Node.EventEmitter (on_)
2425import Node.FS.Aff as FS
2526import Node.FS.Perms (mkPerms)
2627import Node.FS.Perms as Perms
2728import Node.FS.Stats as Stats
2829import Node.FS.Stream (createReadStream, createWriteStream)
29−import Node.Library.Execa (ExecaError, ExecaSuccess, execa)
30+import Node.Library.Execa (ExecaResult, execa)
3031import Node.Library.Execa.Which (defaultWhichOptions, which)
3132import Node.Path (FilePath)
3233import Node.Path as Path
@@ -122,7 +123,7 @@ main cliRoot = do
122123 Right _ -> pure unit
123124 Left err -> do
124125 Console.error (message err)
125− Process.exit 1
126+ Process.exit' 1
126127 Right (Bundle arg) ->
127128 launchAff_ $ runBundle cliRoot arg
128129
@@ -195,18 +196,18 @@ runBundle cliRoot args = do
195196 , " (compile-whole-program \"" <> mainWpoPath <> "\" \"" <> outPath <> "\")"
196197 , ")))"
197198 ]
198− case res of
199− Left err -> liftEffect $ Process.exit (fromMaybe 1 err.exitCode)
200− Right _ -> Console.log $ "Created " <> outPath
199+ case res.exitCode of
200+ Just 0 -> Console.log $ "Created " <> outPath
201+ _ -> liftEffect $ Process.exit' (fromMaybe 1 res.exitCode)
201202
202−evalScheme :: Array String -> String -> Aff (Either ExecaError ExecaSuccess)
203+evalScheme :: Array String -> String -> Aff ExecaResult
203204evalScheme arguments code = do
204205 schemeBin <- getSchemeBinary
205206 spawned <- execa schemeBin arguments identity
206207 spawned.stdin.writeUtf8End code
207− void $ liftEffect $ Stream.pipe spawned.stdout.stream Process.stdout
208− void $ liftEffect $ Stream.pipe spawned.stderr.stream Process.stderr
209− spawned.result
208+ spawned.stdout.pipeToParentStdout
209+ spawned.stderr.pipeToParentStderr
210+ spawned.getResult
210211
211212getSchemeBinary :: Aff String
212213getSchemeBinary = do
@@ -231,13 +232,11 @@ copyFile from to = do
231232 makeAff \k -> do
232233 src <- createReadStream from
233234 dst <- createWriteStream to
234− res <- Stream.pipe src dst
235− Stream.onError src (k <<< Left)
236− Stream.onError dst (k <<< Left)
237− Stream.onError res (k <<< Left)
238− Stream.onFinish res (k (Right unit))
235+ src # on_ Stream.errorH \err -> do
236+ Stream.destroy' dst $ error $ "Got error in src stream: " <> message err
237+ k $ Left err
238+ dst # on_ Stream.errorH (k <<< Left)
239+ Stream.pipe src dst
239240 pure $ effectCanceler do
240− Stream.destroy res
241241 Stream.destroy dst
242242 Stream.destroy src
243−
src/PureScript/Backend/Chez/Builder.purs+1−1
@@ -52,7 +52,7 @@ basicBuildMain options = do
5252 Left errors -> do
5353 for_ errors \(Tuple filePath err) -> do
5454 Console.error $ filePath <> " " <> err
55− liftEffect $ Process.exit 1
55+ liftEffect $ Process.exit' 1
5656 Right coreFnModules -> do
5757 externalDirectives <- map (fromMaybe Map.empty) $ traverse externalDirectivesFromFile
5858 options.externalDirectivesFile
test/Main.purs+12−14
@@ -46,7 +46,7 @@ import PureScript.Backend.Chez.Printer as P
4646import PureScript.Backend.Chez.Runtime (runtimeModule)
4747import PureScript.Backend.Optimizer.Convert (BackendModule)
4848import PureScript.Backend.Optimizer.CoreFn (Comment(..), Module(..), ModuleName(..))
49−import Test.Utils (bufferToUTF8, canRunMain, copyFile, execWithStdin, loadModuleMain, mkdirp, spawnFromParent)
49+import Test.Utils (canRunMain, copyFile, execWithStdin, loadModuleMain, mkdirp, spawnFromParent)
5050
5151type TestArgs =
5252 { accept :: Boolean
@@ -147,21 +147,21 @@ runSnapshotTests { accept, filter } = do
147147 , modulePath: schemeFile
148148 , moduleName: name
149149 }
150− case result of
151− Left { message }
152− | matchesFail message failsWith ->
153− pure true
154− | otherwise -> do
155− Console.log $ withGraphics (foreground Red) "✗" <> " " <> name <> " failed."
156− Console.log message
157− pure false
158− Right _
150+ case result.exitCode of
151+ Just 0
159152 | isJust failsWith -> do
160153 Console.log $ withGraphics (foreground Red) "✗" <> " " <> name <>
161154 " succeeded when it should have failed."
162155 pure false
163156 | otherwise ->
164157 pure true
158+ _
159+ | matchesFail result.message failsWith ->
160+ pure true
161+ | otherwise -> do
162+ Console.log $ withGraphics (foreground Red) "✗" <> " " <> name <> " failed."
163+ Console.log result.message
164+ pure false
165165 attempt (FS.readTextFile UTF8 snapshotFilePath) >>= case _ of
166166 Left _ -> do
167167 Console.log $ withGraphics (foreground Yellow) "✓" <> " " <> name <> " saved."
@@ -176,13 +176,11 @@ runSnapshotTests { accept, filter } = do
176176 runAcceptedTest
177177 | otherwise -> do
178178 Console.log $ withGraphics (foreground Red) "✗" <> " " <> name <> " failed."
179− diff <- bufferToUTF8 <<< _.stdout =<< execWithStdin
180− ("diff " <> snapshotFilePath <> " -")
181− formatted
179+ diff <- _.stdout <$> execWithStdin "diff" [ snapshotFilePath, "-" ] formatted
182180 Console.log diff
183181 pure false
184182 unless (Foldable.and results) do
185− liftEffect $ Process.exit 1
183+ liftEffect $ Process.exit' 1
186184
187185hasFails :: BackendModule -> Maybe String
188186hasFails = findMap go <<< _.comments
test/Utils.purs+26−39
@@ -13,20 +13,15 @@ import Data.Array as Array
1313import Data.Array.NonEmpty as NonEmptyArray
1414import Data.Array.NonEmpty.Internal (NonEmptyArray(..))
1515import Data.Either (Either(..))
16−import Data.Posix.Signal (Signal(..))
17−import Effect.Aff (Aff, effectCanceler, error, makeAff, throwError)
16+import Data.Maybe (Maybe(..))
17+import Effect.Aff (Aff, effectCanceler, error, makeAff, message, throwError)
1818import Effect.Class (liftEffect)
19−import Node.Buffer (Buffer, freeze)
20−import Node.Buffer.Immutable as ImmutableBuffer
21−import Node.ChildProcess (ExecResult, Exit(..), defaultExecOptions, defaultSpawnOptions, inherit)
22−import Node.ChildProcess as ChildProcess
23−import Node.Encoding (Encoding(..))
19+import Node.EventEmitter (on_)
2420import Node.FS.Aff as FS
25−import Node.FS.Perms (mkPerms)
2621import Node.FS.Perms as Perms
2722import Node.FS.Stats as Stats
2823import Node.FS.Stream (createReadStream, createWriteStream)
29−import Node.Library.Execa (ExecaError, ExecaSuccess, execa)
24+import Node.Library.Execa (ExecaResult, execa)
3025import Node.Path (FilePath)
3126import Node.Process as Process
3227import Node.Stream as Stream
@@ -35,29 +30,22 @@ import PureScript.CST.Errors (printParseError)
3530import PureScript.CST.Types as CSTT
3631
3732spawnFromParent :: String -> Array String -> Aff Unit
38−spawnFromParent command args = makeAff \k -> do
39− childProc <- ChildProcess.spawn command args defaultSpawnOptions { stdio = inherit }
40− ChildProcess.onExit childProc case _ of
41− Normally code
42− | code > 0 -> Process.exit code
43− | otherwise -> k (Right unit)
44− BySignal _ ->
45− Process.exit 1
46− pure $ effectCanceler do
47− ChildProcess.kill SIGABRT childProc
33+spawnFromParent command args = do
34+ spawned <- execa command args identity
35+ spawned.stdout.pipeToParentStdout
36+ spawned.stderr.pipeToParentStderr
37+ result <- spawned.getResult
38+ unless (result.exitCode == Just 0) do
39+ liftEffect $ Process.exit' 1
4840
49−execWithStdin :: String -> String -> Aff ExecResult
50−execWithStdin command input = makeAff \k -> do
51− childProc <- ChildProcess.exec command defaultExecOptions (k <<< pure)
52− _ <- Stream.writeString (ChildProcess.stdin childProc) UTF8 input mempty
53− Stream.end (ChildProcess.stdin childProc) mempty
54− pure $ effectCanceler $ ChildProcess.kill SIGABRT childProc
55−
56−bufferToUTF8 :: Buffer -> Aff String
57−bufferToUTF8 = liftEffect <<< map (ImmutableBuffer.toString UTF8) <<< freeze
41+execWithStdin :: String -> Array String -> String -> Aff ExecaResult
42+execWithStdin command args input = do
43+ spawned <- execa command args identity
44+ spawned.stdin.writeUtf8End input
45+ spawned.getResult
5846
5947mkdirp :: FilePath -> Aff Unit
60−mkdirp path = FS.mkdir' path { recursive: true, mode: mkPerms Perms.all Perms.all Perms.all }
48+mkdirp path = FS.mkdir' path { recursive: true, mode: Perms.permsAll }
6149
6250loadModuleMain
6351 :: { libdir :: FilePath
@@ -66,7 +54,7 @@ loadModuleMain
6654 , moduleName :: String
6755 , modulePath :: String
6856 }
69− -> Aff (Either ExecaError ExecaSuccess)
57+ -> Aff ExecaResult
7058loadModuleMain options = do
7159 let
7260 arguments :: Array String
@@ -81,9 +69,9 @@ loadModuleMain options = do
8169 [ "(base-exception-handler (lambda (e) (display-condition e (console-error-port)) (newline (console-error-port)) (exit -1)))"
8270 , "(top-level-program (import (" <> options.moduleName <> " lib)) (main))"
8371 ]
84− void $ liftEffect $ Stream.pipe spawned.stdout.stream Process.stdout
85− void $ liftEffect $ Stream.pipe spawned.stderr.stream Process.stderr
86− spawned.result
72+ spawned.stdout.pipeToParentStdout
73+ spawned.stderr.pipeToParentStderr
74+ spawned.getResult
8775
8876copyFile :: FilePath -> FilePath -> Aff Unit
8977copyFile from to = do
@@ -93,13 +81,12 @@ copyFile from to = do
9381 makeAff \k -> do
9482 src <- createReadStream from
9583 dst <- createWriteStream to
96− res <- Stream.pipe src dst
97− Stream.onError src (k <<< Left)
98− Stream.onError dst (k <<< Left)
99− Stream.onError res (k <<< Left)
100− Stream.onFinish res (k (Right unit))
84+ src # on_ Stream.errorH \err -> do
85+ Stream.destroy' dst $ error $ "Got error in src stream: " <> message err
86+ k $ Left err
87+ dst # on_ Stream.errorH (k <<< Left)
88+ Stream.pipe src dst
10189 pure $ effectCanceler do
102− Stream.destroy res
10390 Stream.destroy dst
10491 Stream.destroy src
10592