Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .eslintrc.json

This file was deleted.

30 changes: 15 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ on:
pull_request:
branches: [master]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: purescript-contrib/setup-purescript@main
with:
purescript: "unstable"
- uses: actions/checkout@v6

- uses: actions/setup-node@v2
- uses: actions/setup-node@v6
with:
node-version: "14.x"
node-version: "24"

- name: Install dependencies
run: |
npm install -g bower
npm install
bower install --production
run: npm install

- name: Build source
run: npm run-script build
run: npm run build

- name: Run tests
run: |
bower install
npm run-script test --if-present
run: npm test

- name: Lint
run: npm run lint

- name: Check formatting
run: npm run format:check
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/.*
!/.gitignore
!/.eslintrc.json
!/.tidyrc.json
!/.oxfmtrc.json
!/.github/
/bower_components/
/node_modules/
/output/
package-lock.json
/package-lock.json
/spago.lock
3 changes: 3 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"trailingComma": "es5"
}
10 changes: 10 additions & 0 deletions .tidyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"importSort": "ide",
"importWrap": "source",
"indent": 2,
"operatorsFile": null,
"ribbon": 1,
"typeArrowPlacement": "first",
"unicode": "never",
"width": null
}
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [Unreleased](https://github.com/purescript/purescript-record/compare/v4.0.1...HEAD)

Breaking changes:

Expand All @@ -12,9 +12,16 @@ Bugfixes:

Other improvements:

## [v4.0.1](https://github.com/purescript/purescript-record/releases/tag/v4.0.1) - 2026-10-17

Other improvements:

- Migrate from Bower/Pulp to Spago and update CI (#87 by @thomashoneyman)

## [v4.0.0](https://github.com/purescript/purescript-record/releases/tag/v4.0.0) - 2022-04-27

Breaking changes:

- Migrate FFI to ES modules (#81 by @kl0tl and @JordanMartinez)
- Replaced polymorphic proxies with monomorphic `Proxy` (#81 by @JordanMartinez)

Expand All @@ -27,17 +34,20 @@ Other improvements:
## [v3.0.0](https://github.com/purescript/purescript-record/releases/tag/v3.0.0) - 2021-02-26

Breaking changes:

- Added support for PureScript 0.14 and dropped support for all previous versions (#66)
- Updated `Record.Builder.merge` and `Record.Builder.union` so that they behave like `Record.merge` and `Record.union`: fields from the argument override those of the record being built in case of overlaps. (#73)
- Removed `Record.ST` (#78)

New features:

- Added `buildFromScratch` for building from an empty record (#53)
- Added `flip` function (#73)

Bugfixes:

Other improvements:

- Replaced monomorphic proxies with `Type.Proxy.Proxy` and polymorphic variants (#67)
- Removed `SProxy` from documentation (#70)
- Migrated CI to GitHub Actions and updated installation instructions to use Spago (#69)
Expand Down
27 changes: 0 additions & 27 deletions bower.json

This file was deleted.

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"private": true,
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "eslint src && pulp build -- --censor-lib --strict",
"test": "pulp test"
"build": "spago build",
"test": "spago test",
"lint": "oxlint --deny-warnings src test",
"format": "purs-tidy format-in-place src test && oxfmt --write .",
"format:check": "purs-tidy check src test && oxfmt --check ."
},
"devDependencies": {
"eslint": "^7.15.0",
"purescript-psa": "^0.8.2",
"pulp": "16.0.0-0",
"rimraf": "^3.0.2"
"oxfmt": "^0.73.0",
"oxlint": "^1.88.0",
"purescript": "^0.15.16",
"purs-tidy": "^0.11.1",
"spago": "^1.0.5"
}
}
25 changes: 25 additions & 0 deletions spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package:
name: record
description: Functions for working with records and polymorphic labels
build:
strict: true
pedanticPackages: true
publish:
version: 4.0.1
license: BSD-3-Clause
location:
githubOwner: purescript
githubRepo: purescript-record
dependencies:
- functions: ">=6.0.0 <7.0.0"
- prelude: ">=6.0.0 <7.0.0"
- unsafe-coerce: ">=6.0.0 <7.0.0"
test:
main: Test.Main
strict: true
pedanticPackages: true
dependencies:
- assert: ">=6.0.0 <7.0.0"
- effect: ">=4.0.0 <5.0.0"

workspace: {}
19 changes: 10 additions & 9 deletions src/Record.purs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import Prelude

import Data.Function.Uncurried (runFn2)
import Data.Symbol (class IsSymbol, reflectSymbol)
import Prim.Row (class Lacks, class Cons, class Nub, class Union)
import Prim.RowList (class RowToList, RowList, Cons, Nil)
import Record.Unsafe (unsafeGet, unsafeSet, unsafeDelete)
import Prim.Row (class Cons, class Lacks, class Nub, class Union)
import Prim.RowList (class RowToList, Cons, Nil, RowList)
import Record.Unsafe (unsafeDelete, unsafeGet, unsafeSet)
import Record.Unsafe.Union (unsafeUnionFn)
import Type.Proxy (Proxy(..))
import Unsafe.Coerce (unsafeCoerce)
Expand Down Expand Up @@ -136,7 +136,8 @@ delete l r = unsafeDelete (reflectSymbol l) r
-- | rename (Proxy :: Proxy "x") (Proxy :: Proxy "y")
-- | :: forall a r. Lacks "x" r => Lacks "y" r => { x :: a | r} -> { y :: a | r}
-- | ```
rename :: forall prev next ty input inter output
rename
:: forall prev next ty input inter output
. IsSymbol prev
=> IsSymbol next
=> Cons prev ty inter input
Expand Down Expand Up @@ -226,17 +227,17 @@ equal a b = equalFields (Proxy :: Proxy rs) a b
class EqualFields (rs :: RowList Type) (row :: Row Type) | rs -> row where
equalFields :: Proxy rs -> Record row -> Record row -> Boolean

instance equalFieldsCons
::
instance equalFieldsCons ::
( IsSymbol name
, Eq ty
, Cons name ty tailRow row
, EqualFields tail row
) => EqualFields (Cons name ty tail) row where
) =>
EqualFields (Cons name ty tail) row where
equalFields _ a b = get' a == get' b && equalRest a b
where
get' = get (Proxy :: Proxy name)
equalRest = equalFields (Proxy :: Proxy tail)
get' = get (Proxy :: Proxy name)
equalRest = equalFields (Proxy :: Proxy tail)

instance equalFieldsNil :: EqualFields Nil row where
equalFields _ _ _ = true
8 changes: 4 additions & 4 deletions src/Record/Builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export function copyRecord(rec) {
}

export function unsafeInsert(l) {
return function(a) {
return function(rec) {
return function (a) {
return function (rec) {
rec[l] = a;
return rec;
};
Expand All @@ -19,15 +19,15 @@ export function unsafeInsert(l) {

export function unsafeModify(l) {
return function (f) {
return function(rec) {
return function (rec) {
rec[l] = f(rec[l]);
return rec;
};
};
}

export function unsafeDelete(l) {
return function(rec) {
return function (rec) {
delete rec[l];
return rec;
};
Expand Down
11 changes: 6 additions & 5 deletions src/Record/Builder.purs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,15 @@ modify l f = Builder \r1 -> unsafeModify (reflectSymbol l) f r1
delete
:: forall l a r1 r2
. IsSymbol l
=> Row.Lacks l r1
=> Row.Cons l a r1 r2
=> Proxy l
-> Builder (Record r2) (Record r1)
=> Row.Lacks l r1
=> Row.Cons l a r1 r2
=> Proxy l
-> Builder (Record r2) (Record r1)
delete l = Builder \r2 -> unsafeDelete (reflectSymbol l) r2

-- | Build by renaming an existing field.
rename :: forall l1 l2 a r1 r2 r3
rename
:: forall l1 l2 a r1 r2 r3
. IsSymbol l1
=> IsSymbol l2
=> Row.Cons l1 a r2 r1
Expand Down
2 changes: 1 addition & 1 deletion test/Examples.purs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ setX2 = Record.set x_ unit { x: 0 }
modifyX :: { x :: Int }
modifyX = Record.modify x_ (\value -> value + 1) { x: 0 }

mergedXY :: { x :: Int , y :: Int }
mergedXY :: { x :: Int, y :: Int }
mergedXY = Record.merge { x: 1 } { y: 1 }
Loading
Loading