Skip to content

Commit 45877a1

Browse files
Update for PureScript 0.15 (#22)
1 parent 6943522 commit 45877a1

File tree

7 files changed

+25
-51
lines changed

7 files changed

+25
-51
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
- uses: actions/checkout@v2
1414
- uses: purescript-contrib/setup-purescript@main
1515
with:
16-
purescript: "0.14.4"
16+
purescript: "0.15.0"
1717
psa: "0.8.2"
18-
spago: "latest"
19-
purs-tidy: "latest"
18+
spago: "0.20.9"
19+
purs-tidy: "0.8.0"
2020
- uses: actions/cache@v2
2121
# This cache uses the .dhall files to know when it should reinstall
2222
# and rebuild packages. It caches both the installed packages from

packages.dhall

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,9 @@
11
let upstream =
2-
https://github.com/purescript/package-sets/releases/download/psc-0.14.3-20210811/packages.dhall sha256:a2de7ef2f2e753733eddfa90573a82da0c7c61d46fa87d015b7f15ef8a6e97d5
2+
https://github.com/purescript/package-sets/releases/download/psc-0.15.0-20220513/packages.dhall
3+
sha256:1ed784f37ae6131d99acd542d058d5ce39954ccaacc3adba5cc7cf1549d2bffa
34

45
let additions =
5-
{ dodo-printer =
6-
{ dependencies =
7-
[ "ansi", "foldable-traversable", "lists", "maybe", "strings" ]
8-
, repo = "https://github.com/natefaubion/purescript-dodo-printer.git"
9-
, version = "v2.1.0"
10-
}
11-
, language-cst-parser =
12-
{ dependencies =
13-
[ "arrays"
14-
, "const"
15-
, "effect"
16-
, "either"
17-
, "foldable-traversable"
18-
, "free"
19-
, "functors"
20-
, "maybe"
21-
, "numbers"
22-
, "ordered-collections"
23-
, "strings"
24-
, "transformers"
25-
, "tuples"
26-
, "typelevel-prelude"
27-
]
28-
, repo =
29-
"https://github.com/natefaubion/purescript-language-cst-parser.git"
30-
, version = "v0.9.1"
31-
}
32-
, tidy =
6+
{ tidy =
337
{ dependencies =
348
[ "arrays"
359
, "dodo-printer"
@@ -43,9 +17,8 @@ let additions =
4317
, "strings"
4418
, "tuples"
4519
]
46-
, repo =
47-
"https://github.com/natefaubion/purescript-tidy.git"
48-
, version = "v0.7.0"
20+
, repo = "https://github.com/natefaubion/purescript-tidy.git"
21+
, version = "v0.9.0"
4922
}
5023
}
5124

spago.dhall

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
{-
2-
Welcome to a Spago project!
3-
You can edit this file as you like.
4-
5-
Need help? See the following resources:
6-
- Spago documentation: https://github.com/purescript/spago
7-
- Dhall language tour: https://docs.dhall-lang.org/tutorials/Language-Tour.html
8-
9-
When creating a new Spago project, you can use
10-
`spago init --no-comments` or `spago init -C`
11-
to generate this file without the comments in this block.
12-
-}
131
{ name = "tidy-codegen"
142
, dependencies =
153
[ "aff"

src/Tidy/Codegen.purs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ module Tidy.Codegen
122122
, typeRow
123123
, typeRowEmpty
124124
, typeString
125+
, typeInt
125126
, typeVar
126127
, typeVarKinded
127128
, typeWildcard
@@ -328,6 +329,17 @@ typeRecordEmpty = typeRecord ([] :: Array (Tuple Label _)) Nothing
328329
typeString :: forall e. String -> CST.Type e
329330
typeString str = TypeString (toSourceToken (TokString (unwrap (escapeSourceString str)) str)) str
330331

332+
-- | Constructs a type-level int
333+
-- |
334+
-- | ```
335+
-- | exampleType = typeInt (-1)
336+
-- | ```
337+
typeInt :: forall e. Int -> CST.Type e
338+
typeInt n = TypeInt neg (toSourceToken (TokInt (show val) (SmallInt val))) (SmallInt val)
339+
where
340+
val = abs n
341+
neg = if n < 0 then Just tokNegate else Nothing
342+
331343
-- | Constructs a type with a kind annotation.
332344
-- |
333345
-- | ```purescript

src/Tidy/Codegen/Class.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,8 @@ instance OverLeadingComments e => OverLeadingComments (CST.Type e) where
541541
TypeWildcard a -> TypeWildcard (overLeadingComments k a)
542542
TypeHole a -> TypeHole (overLeadingComments k a)
543543
TypeString a b -> TypeString (overLeadingComments k a) b
544+
TypeInt (Just a) b c -> TypeInt (Just (overLeadingComments k a)) b c
545+
TypeInt _ b c -> TypeInt Nothing (overLeadingComments k b) c
544546
TypeRow a -> TypeRow (overLeadingComments k a)
545547
TypeRecord a -> TypeRecord (overLeadingComments k a)
546548
TypeForall a b c d -> TypeForall (overLeadingComments k a) b c d
@@ -552,7 +554,6 @@ instance OverLeadingComments e => OverLeadingComments (CST.Type e) where
552554
TypeArrowName a -> TypeArrowName (overLeadingComments k a)
553555
TypeConstrained a b c -> TypeConstrained (overLeadingComments k a) b c
554556
TypeParens a -> TypeParens (overLeadingComments k a)
555-
TypeUnaryRow a b -> TypeUnaryRow (overLeadingComments k a) b
556557
TypeError e -> TypeError (overLeadingComments k e)
557558

558559
instance OverLeadingComments e => OverLeadingComments (Expr e) where

test/Snapshot.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Test.Snapshot where
22

33
import Prelude
44

5-
import Control.MonadZero (guard)
5+
import Control.Alternative (guard)
66
import Control.Parallel (parTraverse)
77
import Data.Array (mapMaybe)
88
import Data.Array as Array
@@ -72,7 +72,7 @@ snapshotMainOutput directory accept mbPattern = do
7272

7373
runSnapshot :: String -> Aff SnapshotTest
7474
runSnapshot name = flip catchError (makeErrorResult name) do
75-
result <- exec $ "node -e 'require(\"./output/" <> name <> "/index.js\").main()'"
75+
result <- exec $ "node --input-type=module -e 'import { main } from \"./output/" <> name <> "/index.js\";main()'"
7676
case result of
7777
{ error: Just err } ->
7878
throwError err

test/snapshots/CodegenMonad.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Partial.Unsafe (unsafePartial)
77
import PureScript.CST.Types (Module)
88
import Test.Util (log)
99
import Tidy.Codegen (binaryOp, binderVar, declSignature, declValue, exprApp, exprCtor, exprIdent, exprInt, exprOp, exprOpName, printModule, typeApp, typeArrow, typeCtor)
10-
import Tidy.Codegen.Monad (codegenModule, exporting, importCtor, importFrom, importOp, importOpen, importType, importTypeOp, importValue, write)
10+
import Tidy.Codegen.Monad (codegenModule, exporting, importCtor, importFrom, importOp, importOpen, importType, importValue, write)
1111

1212
test :: Module Void
1313
test = unsafePartial do

0 commit comments

Comments
 (0)