Skip to content

Commit f6e2fc1

Browse files
Update for PureScript 0.14 (#9)
* Update for PureScript 0.14 * integration -> parse-package-set * avoid double-map in traversals * Prim -> P * fix missing space in imports * Add PS prefix to avoid conflicts with Prim * Update readme, remove unused import * Revert "Add PS prefix to avoid conflicts with Prim" This reverts commit 6f8b2e8. * Update README * Use 0.14 in CI * Update Range.purs * Update Range.purs * Update imports
1 parent c5997dc commit f6e2fc1

File tree

16 files changed

+118
-55
lines changed

16 files changed

+118
-55
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111

1212
steps:
1313
- uses: actions/checkout@v2
14-
14+
1515
- uses: purescript-contrib/setup-purescript@main
1616
with:
17-
purescript: "0.13.8"
17+
purescript: "0.14.0"
1818
spago: "0.19.0"
1919
psa: "0.8.2"
2020

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ import Data.Set (Set)
4141
import Data.Set as Set
4242
import Data.Tuple (Tuple(..))
4343
import PureScript.CST.Traversal (foldMapModule, defaultMonoidalVisitor)
44-
import PureScript.CST.Types (Expr(..), Ident, Module, ModuleName, QualifiedName(..), SourceRange)
44+
import PureScript.CST.Types as CST
4545
46-
type QualifiedIdent = Tuple (Maybe ModuleName) Ident
47-
type UsageMap = SemigroupMap QualifiedIdent (Set SourceRange)
46+
type QualifiedIdent = Tuple (Maybe CST.ModuleName) CST.Ident
47+
type UsageMap = SemigroupMap QualifiedIdent (Set CST.SourceRange)
4848
49-
getExprIdents :: forall a. Module a -> UsageMap
49+
getExprIdents :: forall a. CST.Module a -> UsageMap
5050
getExprIdents = foldMapModule $ defaultMonoidalVisitor
5151
{ onExpr = case _ of
52-
ExprIdent (QualifiedName ident) ->
52+
CST.ExprIdent (CST.QualifiedName ident) ->
5353
SemigroupMap
54-
$ Map.singleton (Tuple ident.module ident.name)
54+
$ Map.singleton (Tuple ident."module" ident.name)
5555
$ Set.singleton ident.token.range
5656
_ -> mempty
5757
}
@@ -66,3 +66,9 @@ slowest parse times along with the mean parse time for the set.
6666
```sh
6767
npm run parse-package-set
6868
```
69+
70+
You can also benchmark a single file:
71+
72+
```sh
73+
npm run bench-file MyModule.purs
74+
```

bench.dhall renamed to bench/bench.dhall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
let conf = ./spago.dhall
1+
let conf = ../spago.dhall
22

33
in conf // {
44
sources = conf.sources # [ "bench/**/*.purs" ],

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"private": true,
33
"scripts": {
4-
"parse-package-set": "spago -x integration.dhall run",
5-
"bench-file": "spago -x bench.dhall build && node --expose-gc -e \"require('./output/BenchFile/index.js').main()\""
4+
"parse-package-set": "spago -x parse-package-set/parse-package-set.dhall run",
5+
"bench-file": "spago -x bench/bench.dhall build && node --expose-gc -e \"require('./output/BenchFile/index.js').main()\""
66
},
77
"devDependencies": {
8-
"purescript": "^0.13.8",
9-
"spago": "^0.19.0"
8+
"purescript": "^0.14.0",
9+
"spago": "^0.19.1"
1010
}
1111
}

packages.dhall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
let upstream =
2-
https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20200922/packages.dhall sha256:5edc9af74593eab8834d7e324e5868a3d258bbab75c5531d2eb770d4324a2900
2+
https://github.com/purescript/package-sets/releases/download/psc-0.14.0-20210304/packages.dhall sha256:c88151fe7c05f05290224c9c1ae4a22905060424fb01071b691d3fe2e5bad4ca
33

44
in upstream
File renamed without changes.

integration/Main.purs renamed to parse-package-set/Main.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ defaultSpagoDhall :: String
159159
defaultSpagoDhall = Array.intercalate "\n"
160160
[ "{ name = \"test-parser\""
161161
, ", dependencies = [] : List Text"
162-
, ", packages = https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20200922/packages.dhall sha256:5edc9af74593eab8834d7e324e5868a3d258bbab75c5531d2eb770d4324a2900"
162+
, ", packages = https://github.com/purescript/package-sets/releases/download/psc-0.14.0-20210304/packages.dhall sha256:c88151fe7c05f05290224c9c1ae4a22905060424fb01071b691d3fe2e5bad4ca"
163163
, ", sources = [] : List Text"
164164
, "}"
165165
]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
let conf = ./spago.dhall
1+
let conf = ../spago.dhall
22

33
in conf // {
4-
sources = conf.sources # [ "integration/**/*.purs" ],
4+
sources = conf.sources # [ "parse-package-set/**/*.purs" ],
55
dependencies = conf.dependencies # [ "node-fs", "node-fs-aff", "strings", "node-child-process", "console", "avar", "now", "numbers" ]
66
}

src/PureScript/CST.purs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Data.Lazy as Z
2121
import Data.Maybe (Maybe(..))
2222
import Data.Newtype (unwrap)
2323
import Data.Tuple (Tuple(..))
24+
import Prim hiding (Type)
2425
import PureScript.CST.Lexer (lex)
2526
import PureScript.CST.Parser (Recovered, parseModuleBody, parseModuleHeader)
2627
import PureScript.CST.Parser as Parser

src/PureScript/CST/Lexer.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ module PureScript.CST.Lexer
66
import Prelude
77

88
import Control.Alt (class Alt, (<|>))
9-
import Data.Array (fold, foldMap, foldl)
109
import Data.Array as Array
1110
import Data.Array.NonEmpty as NonEmptyArray
1211
import Data.Char as Char
12+
import Data.Foldable (fold, foldl, foldMap)
1313
import Data.Int (hexadecimal)
1414
import Data.Int as Int
1515
import Data.Lazy as Lazy

src/PureScript/CST/Parser.purs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ import Data.Maybe (Maybe(..), maybe)
2222
import Data.Set (Set)
2323
import Data.Set as Set
2424
import Data.Tuple (Tuple(..), uncurry)
25+
import Prim as P
26+
import Prim hiding (Type, Row)
2527
import PureScript.CST.Errors (ParseError(..), RecoveredError(..))
2628
import PureScript.CST.Layout (currentIndent)
2729
import PureScript.CST.Parser.Monad (Parser, Recovery(..), eof, lookAhead, many, optional, recover, take, try)
2830
import PureScript.CST.TokenStream (TokenStep(..), TokenStream, layoutStack)
2931
import PureScript.CST.TokenStream as TokenStream
3032
import PureScript.CST.Types (Binder(..), ClassFundep(..), DataCtor(..), DataMembers(..), Declaration(..), Delimited, DoStatement(..), Export(..), Expr(..), Fixity(..), FixityOp(..), Foreign(..), Guarded(..), GuardedExpr(..), Ident(..), Import(..), ImportDecl(..), Instance(..), InstanceBinding(..), Label(..), Labeled(..), LetBinding(..), Module(..), ModuleBody(..), ModuleHeader(..), ModuleName(..), Name(..), OneOrDelimited(..), Operator(..), PatternGuard(..), Proper(..), QualifiedName(..), RecordLabeled(..), RecordUpdate(..), Role(..), Row(..), Separated(..), SourceToken, Token(..), Type(..), TypeVarBinding(..), Where(..), Wrapped(..))
3133

34+
type Recovered :: (P.Type -> P.Type) -> P.Type
3235
type Recovered f = f RecoveredError
3336

3437
type RecoveryStrategy f = Parser (Recovered f) -> Parser (Recovered f)

src/PureScript/CST/Parser/Monad.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ foldMaybe = mkFold
110110
foldArray :: forall a. Fold a (Array a)
111111
foldArray = mkFold
112112
{ init: \_ ->
113-
unsafePerformEffect $ liftST STArray.empty
113+
unsafePerformEffect $ liftST STArray.new
114114
, step: \arr a ->
115115
unsafePerformEffect $ liftST do
116116
_ <- STArray.push a arr

src/PureScript/CST/Range.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ module PureScript.CST.Range
88
import Prelude
99

1010
import Control.Lazy (defer)
11-
import Data.Array (foldMap)
1211
import Data.Array as Array
1312
import Data.Array.NonEmpty (NonEmptyArray)
1413
import Data.Array.NonEmpty as NonEmptyArray
14+
import Data.Foldable (foldMap)
1515
import Data.Maybe (Maybe(..), maybe)
1616
import Data.Tuple (Tuple(..), fst, snd)
17+
import Prim hiding (Row, Type)
1718
import PureScript.CST.Errors (RecoveredError(..))
1819
import PureScript.CST.Range.TokenList (TokenList, cons, singleton)
1920
import PureScript.CST.Range.TokenList as TokenList

src/PureScript/CST/Range/TokenList.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ toUnfoldable = unfoldr (uncons' Nothing (\a b -> Just (Tuple a b)))
109109

110110
toArray :: TokenList -> Array SourceToken
111111
toArray init = ST.run do
112-
arr <- STArray.empty
112+
arr <- STArray.new
113113
cur <- STRef.new init
114114
continue <- STRef.new true
115115
ST.while (STRef.read continue) do

0 commit comments

Comments
 (0)