Skip to content

Commit 6e996a3

Browse files
committed
Updates for PS 0.15 and related workflow improvements
1 parent 66c906e commit 6e996a3

18 files changed

+278
-102
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 71 additions & 0 deletions
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

Lines changed: 34 additions & 0 deletions
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

Lines changed: 10 additions & 0 deletions
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

Lines changed: 0 additions & 3 deletions
This file was deleted.

bower.json

Lines changed: 28 additions & 0 deletions
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

Lines changed: 13 additions & 0 deletions
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

Lines changed: 8 additions & 4 deletions
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

Lines changed: 4 additions & 3 deletions
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

Lines changed: 5 additions & 4 deletions
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

0 commit comments

Comments
 (0)