Skip to content

Commit 27a81c5

Browse files
authored
Updates for PS 0.15 and related workflow improvements (#5)
1 parent 66c906e commit 27a81c5

18 files changed

+278
-102
lines changed

.github/workflows/build.yml

-16
This file was deleted.

.github/workflows/ci.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths:
7+
- 'examples/**/*.purs'
8+
- 'examples/**/*.js'
9+
- 'src/**/*.purs'
10+
- 'src/**/*.js'
11+
- 'test/**/*.purs'
12+
- 'test/**/*.js'
13+
- '*.json'
14+
- '*.dhall'
15+
- '.github/workflows/ci.yml'
16+
pull_request:
17+
branches: [master]
18+
paths:
19+
- 'examples/**/*.purs'
20+
- 'examples/**/*.js'
21+
- 'src/**/*.purs'
22+
- 'src/**/*.js'
23+
- 'test/**/*.purs'
24+
- 'test/**/*.js'
25+
- '*.json'
26+
- '*.dhall'
27+
- '.github/workflows/ci.yml'
28+
29+
jobs:
30+
build:
31+
name: Build
32+
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
- uses: actions/checkout@v3
37+
38+
- name: Set up a PureScript toolchain
39+
uses: purescript-contrib/setup-purescript@main
40+
with:
41+
purescript: "unstable"
42+
purs-tidy: "latest"
43+
44+
- name: Cache PureScript dependencies
45+
uses: actions/cache@v2
46+
with:
47+
key: ${{ runner.os }}-spago-${{ hashFiles('**/*.dhall') }}
48+
path: |
49+
.spago
50+
output
51+
52+
- name: Install PureScript dependencies
53+
run: spago install
54+
55+
- name: Build source
56+
run: spago build --no-install --purs-args '--censor-lib --strict'
57+
58+
- name: Build examples
59+
run: spago -x example.dhall build
60+
61+
- name: Run tests
62+
run: spago -x test.dhall test
63+
64+
- name: Check formatting
65+
run: purs-tidy check examples src test
66+
67+
- name: Verify Bower & Pulp
68+
run: |
69+
npm install bower [email protected]
70+
npx bower install
71+
npx pulp build -- --censor-lib --strict

.github/workflows/traffic.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Traffic
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths:
7+
- '.github/workflows/traffic.yml'
8+
schedule:
9+
- cron: "15 23 * * 0"
10+
11+
jobs:
12+
update:
13+
name: Update
14+
15+
runs-on: ubuntu-latest
16+
17+
env:
18+
TRAFFIC_PATH: .github/traffic.json
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- uses: nsaunders/traffic-lite@v1
24+
with:
25+
path: ${{ env.TRAFFIC_PATH }}
26+
repo: ${{ github.repository }}
27+
token: ${{ secrets.GH_ACCESS_TOKEN }}
28+
29+
- uses: EndBug/add-and-commit@v9
30+
with:
31+
add: ${{ env.TRAFFIC_PATH }}
32+
author_name: GitHub Actions
33+
author_email: 41898282+github-actions[bot]@users.noreply.github.com
34+
message: Log repository traffic.

.tidyrc.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"importSort": "ide",
3+
"importWrap": "auto",
4+
"indent": 2,
5+
"operatorsFile": null,
6+
"ribbon": 1,
7+
"typeArrowPlacement": "first",
8+
"unicode": "never",
9+
"width": 80
10+
}

.tool-versions

-3
This file was deleted.

bower.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "purescript-typedenv",
3+
"license": [
4+
"MIT"
5+
],
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/nsaunders/purescript-typedenv"
9+
},
10+
"ignore": [
11+
"**/.*",
12+
"node_modules",
13+
"bower_components",
14+
"output"
15+
],
16+
"dependencies": {
17+
"purescript-either": "^v6.1.0",
18+
"purescript-foreign-object": "^v4.0.0",
19+
"purescript-integers": "^v6.0.0",
20+
"purescript-maybe": "^v6.0.0",
21+
"purescript-numbers": "^v9.0.0",
22+
"purescript-prelude": "^v6.0.0",
23+
"purescript-record": "^v4.0.0",
24+
"purescript-strings": "^v6.0.0",
25+
"purescript-type-equality": "^v4.0.1",
26+
"purescript-typelevel-prelude": "^v7.0.0"
27+
}
28+
}

example.dhall

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
let conf = ./spago.dhall
2+
3+
in conf // {
4+
sources = conf.sources # [ "examples/**/*.purs" ],
5+
dependencies = conf.dependencies #
6+
[ "console"
7+
, "effect"
8+
, "foldable-traversable"
9+
, "lists"
10+
, "node-process"
11+
, "transformers"
12+
]
13+
}

example/App.purs renamed to examples/App.purs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
module Example.App where
22

33
import Prelude
4+
45
import Control.Monad.Reader (ReaderT, asks, runReaderT)
56
import Control.Monad.Reader.Class (class MonadAsk)
67
import Data.Either (Either(..))
78
import Effect (Effect)
89
import Effect.Class (class MonadEffect, liftEffect)
910
import Effect.Console (log)
1011
import Node.Process (getEnv)
11-
import Type.Data.Row (RProxy(..))
1212
import Type.Equality (class TypeEquals, from)
13+
import Type.Proxy (Proxy(..))
1314
import TypedEnv (Resolved, Variable, envErrorMessage)
1415
import TypedEnv (fromEnv) as TypedEnv
1516

1617
type Config f =
17-
( alertEmail :: f "ALERT_EMAIL" String
18+
( alertEmail :: f "ALERT_EMAIL" String
1819
, alertSubject :: f "ALERT_SUBJECT" String
1920
)
2021

@@ -37,7 +38,7 @@ instance monadAskAppM :: TypeEquals e ResolvedConfig => MonadAsk e AppM where
3738

3839
main :: Effect Unit
3940
main = do
40-
eitherConfig <- TypedEnv.fromEnv (RProxy :: RProxy (Config Variable)) <$> getEnv
41+
eitherConfig <- TypedEnv.fromEnv (Proxy :: Proxy (Config Variable)) <$> getEnv
4142
case eitherConfig of
4243
Left error ->
4344
log $ "ERROR: " <> envErrorMessage error
@@ -48,4 +49,7 @@ sendAlert :: AppM Unit
4849
sendAlert = do
4950
email <- asks _.alertEmail
5051
subject <- asks _.alertSubject
51-
liftEffect $ log ("Sending alert with subject \"" <> subject <> "\" to \"" <> email <> "\"...done.")
52+
liftEffect $ log
53+
( "Sending alert with subject \"" <> subject <> "\" to \"" <> email <>
54+
"\"...done."
55+
)

example/Basic.purs renamed to examples/Basic.purs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
module Example.Basic where
22

33
import Prelude
4+
45
import Data.Either (Either(..))
56
import Data.List.Lazy (replicateM)
67
import Effect (Effect)
78
import Effect.Console (log)
89
import Node.Process (getEnv)
9-
import Type.Data.Row (RProxy(..))
10+
import Type.Proxy (Proxy(..))
1011
import TypedEnv (type (<:), envErrorMessage)
1112
import TypedEnv (fromEnv) as TypedEnv
1213

1314
type Environment =
1415
( greeting :: String <: "GREETING"
15-
, count :: Int <: "COUNT"
16+
, count :: Int <: "COUNT"
1617
)
1718

1819
main :: Effect Unit
1920
main = do
20-
env <- TypedEnv.fromEnv (RProxy :: RProxy Environment) <$> getEnv
21+
env <- TypedEnv.fromEnv (Proxy :: Proxy Environment) <$> getEnv
2122
case env of
2223
Left error ->
2324
log $ "ERROR: " <> envErrorMessage error

example/CustomType.purs renamed to examples/CustomType.purs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
module Example.CustomType where
22

33
import Prelude
4+
45
import Data.Either (Either(..))
56
import Data.Foldable (find)
67
import Data.Int (fromString) as Int
78
import Effect (Effect)
89
import Effect.Console (log)
910
import Node.Process (getEnv)
10-
import Type.Data.Row (RProxy(..))
11-
import TypedEnv (type (<:), class ParseValue, envErrorMessage)
11+
import Type.Proxy (Proxy(..))
12+
import TypedEnv (class ParseValue, type (<:), envErrorMessage)
1213
import TypedEnv (fromEnv) as TypedEnv
1314

1415
newtype Port = Port Int
@@ -21,12 +22,12 @@ instance parseValuePort :: ParseValue Port where
2122

2223
type Settings =
2324
( host :: String <: "HOST"
24-
, port :: Port <: "PORT"
25+
, port :: Port <: "PORT"
2526
)
2627

2728
main :: Effect Unit
2829
main = do
29-
env <- TypedEnv.fromEnv (RProxy :: RProxy Settings) <$> getEnv
30+
env <- TypedEnv.fromEnv (Proxy :: Proxy Settings) <$> getEnv
3031
case env of
3132
Left error ->
3233
log $ "ERROR: " <> envErrorMessage error

example/Optional.purs renamed to examples/Optional.purs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
module Example.Optional where
22

33
import Prelude
4+
45
import Data.Either (Either(..))
56
import Data.Maybe (Maybe, fromMaybe)
67
import Effect (Effect)
78
import Effect.Console (log)
89
import Node.Process (getEnv)
9-
import Type.Data.Row (RProxy(..))
10+
import Type.Proxy (Proxy(..))
1011
import TypedEnv (type (<:), envErrorMessage)
1112
import TypedEnv (fromEnv) as TypedEnv
1213

13-
type Settings = ( username :: Maybe String <: "USERNAME" )
14+
type Settings = (username :: Maybe String <: "USERNAME")
1415

1516
main :: Effect Unit
1617
main = do
17-
env <- TypedEnv.fromEnv (RProxy :: RProxy Settings) <$> getEnv
18+
env <- TypedEnv.fromEnv (Proxy :: Proxy Settings) <$> getEnv
1819
case env of
1920
Left error ->
2021
log $ "ERROR: " <> envErrorMessage error
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
module Example.Reader where
22

33
import Prelude
4+
45
import Control.Monad.Reader (Reader, asks, runReader)
56
import Data.Either (Either(..))
67
import Data.List.Lazy (replicateM)
78
import Data.Maybe (Maybe, fromMaybe)
89
import Effect (Effect)
910
import Effect.Console (log)
1011
import Node.Process (getEnv)
11-
import Type.Data.Row (RProxy(..))
12+
import Type.Proxy (Proxy(..))
1213
import TypedEnv (type (<:), envErrorMessage)
1314
import TypedEnv (fromEnv) as TypedEnv
1415

1516
type Config =
1617
( username :: Maybe String <: "USERNAME"
17-
, repeat :: Maybe Int <: "REPEAT"
18+
, repeat :: Maybe Int <: "REPEAT"
1819
)
1920

2021
main :: Effect Unit
2122
main = do
22-
env <- TypedEnv.fromEnv (RProxy :: RProxy Config) <$> getEnv
23+
env <- TypedEnv.fromEnv (Proxy :: Proxy Config) <$> getEnv
2324
case env of
2425
Left error ->
2526
log $ "ERROR: " <> envErrorMessage error
@@ -28,4 +29,6 @@ main = do
2829
pure unit
2930

3031
greeting :: forall r. Reader { username :: Maybe String | r } String
31-
greeting = asks _.username >>= \username -> pure $ "Hello, " <> fromMaybe "Sailor" username <> "!"
32+
greeting = asks _.username >>= \username -> pure $ "Hello, "
33+
<> fromMaybe "Sailor" username
34+
<> "!"

packages.dhall

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ let mkPackage =
22
https://raw.githubusercontent.com/purescript/package-sets/psc-0.13.0-20190626/src/mkPackage.dhall sha256:0b197efa1d397ace6eb46b243ff2d73a3da5638d8d0ac8473e8e4a8fc528cf57
33

44
let upstream =
5-
https://github.com/purescript/package-sets/releases/download/psc-0.14.0-20210324/packages.dhall sha256:b4564d575da6aed1c042ca7936da97c8b7a29473b63f4515f09bb95fae8dddab
5+
https://github.com/purescript/package-sets/releases/download/psc-0.15.2-20220706/packages.dhall sha256:7a24ebdbacb2bfa27b2fc6ce3da96f048093d64e54369965a2a7b5d9892b6031
66

77
let overrides = {=}
88

0 commit comments

Comments
 (0)