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.

34 changes: 12 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,20 @@ 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/setup-node@v2
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: "14.x"

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

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

- name: Run tests
run: |
bower install
npm run-script test --if-present
node-version: "24"
- run: npm install
- run: npm run build
- run: npm test
- run: npm run bench
- run: npm run lint
- 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
}
22 changes: 19 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,37 @@

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-strings/compare/v6.1.0...HEAD)

Breaking changes:

New features:
- Added `startsWith` and `endsWith` (#147)

Bugfixes:

Other improvements:

## [v6.1.0](https://github.com/purescript/purescript-strings/releases/tag/v6.1.0) - 2026-10-17

New features:

- Added `startsWith` and `endsWith` (#147)

Other improvements:

- Migrate from Bower/Pulp to Spago and update CI (#178 by @thomashoneyman)
- Redefine `Data.String.NonEmpty.CodeUnits.fromFoldable1` in terms of `singleton` (#168 by @postsolar)

## [v6.0.1](https://github.com/purescript/purescript-strings/releases/tag/v6.0.1) - 2022-08-16

Bugfixes:

- Fix `Char`'s `toEnum` implementation (#163 by @JordanMartinez)

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

Breaking changes:

- Migrate FFI to ES modules (#158 by @kl0tl and @JordanMartinez)
- Replaced polymorphic proxies with monomorphic `Proxy` (#158 by @JordanMartinez)
- In `slice`, drop bounds checking and `Maybe` return type (#145 by Quelklef)
Expand All @@ -31,24 +42,29 @@ New features:
Bugfixes:

Other improvements:

- Surround code with backticks in documentation (#148)
- Make `RegexFlags` a `newtype` and a `Newtype` instance for it(#159 by @mhmdanas)

## [v5.0.0](https://github.com/purescript/purescript-strings/releases/tag/v5.0.0) - 2021-02-26

Breaking changes:

- Added support for PureScript 0.14 and dropped support for all previous versions (#129)
- Updated `replace'` to reflect the existence of optional capturing groups (#126)

New features:

- Replaced `unsafeCoerce` with `coerce` where appropriate (#130)
- Replaced monomorphic proxies with `Type.Proxy.Proxy` and polymorphic variables (#134)
- Added a dotAll regexp flag (#133)

Bugfixes:

- Removed the bounds check from the foreign implementation of `lastIndexOf'` (#137)

Other improvements:

- Fix line endings to match overall project style (#132)
- Removed references to `codePointToInt`, which no longer exists (#135)
- Migrated CI to GitHub Actions and updated installation instructions to use Spago (#136)
Expand Down Expand Up @@ -129,7 +145,7 @@ Other improvements:

- Updated dependencies
- `Pattern` and `Replacement` newtypes are now used to distinguish between arguments when a function accepts multiple strings
- `RegexFlags` have been reworked as a monoid (@Risto-Stevcev)
- `RegexFlags` have been reworked as a monoid (@Risto-Stevcev)

## [v1.1.0](https://github.com/purescript/purescript-strings/releases/tag/v1.1.0) - 2016-07-20

Expand Down
14 changes: 14 additions & 0 deletions bench/spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package:
name: strings-bench
build:
strict: true
pedanticPackages: true
dependencies:
- arrays: ">=7.0.0 <8.0.0"
- console: ">=6.0.0 <7.0.0"
- effect: ">=4.0.0 <5.0.0"
- maybe: ">=6.0.0 <7.0.0"
- minibench: ">=4.0.0 <5.0.0"
- partial: ">=4.0.0 <5.0.0"
- prelude: ">=6.0.0 <7.0.0"
- strings: "*"
12 changes: 6 additions & 6 deletions bench/Main.purs → bench/src/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ module Bench.Main where

import Prelude

import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
import Data.Array.NonEmpty (fromArray)
import Data.Maybe (fromJust)
import Data.String (toCharArray)
import Data.String.NonEmpty (fromFoldable1, fromNonEmptyCharArray)
import Data.String.CodeUnits (toCharArray)
import Data.String.NonEmpty.CodeUnits (fromFoldable1, fromNonEmptyCharArray)
import Effect (Effect)
import Effect.Console (log)
import Partial.Unsafe (unsafePartial)
import Performance.Minibench (benchWith)

main :: Eff (console :: CONSOLE) Unit
main :: Effect Unit
main = do
log "NonEmpty conversions"
log "======"
log ""
benchNonEmptyConversions

benchNonEmptyConversions :: Eff (console :: CONSOLE) Unit
benchNonEmptyConversions :: Effect Unit
benchNonEmptyConversions = do
log "fromNonEmptyCharArray: short"
log "---"
Expand Down
41 changes: 0 additions & 41 deletions bower.json

This file was deleted.

23 changes: 13 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{
"private": true,
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "eslint src && pulp build -- --censor-lib --strict",
"test": "pulp test && npm run test:run:without_codePointAt",
"build": "spago build",
"test": "spago test -p strings && npm run test:run:without_codePointAt",
"test:run:without_codePointAt": "node -e \"delete String.prototype.codePointAt; import('./output/Test.Main/index.js').then(m => m.main());\"",
"bench:build": "purs compile 'bench/**/*.purs' 'src/**/*.purs' 'bower_components/*/src/**/*.purs'",
"bench:run": "node --expose-gc -e 'require(\"./output/Bench.Main/index.js\").main()'",
"bench": "npm run bench:build && npm run bench:run"
"bench:build": "spago build -p strings-bench",
"bench:run": "node --expose-gc -e \"import('./output/Bench.Main/index.js').then(m => m.main());\"",
"bench": "npm run bench:build && npm run bench:run",
"lint": "oxlint --deny-warnings src test",
"format": "purs-tidy format-in-place src test bench/src && oxfmt --write .",
"format:check": "purs-tidy check src test bench/src && oxfmt --check ."
},
"devDependencies": {
"eslint": "^7.15.0",
"pulp": "16.0.0-0",
"purescript-psa": "^0.8.2",
"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"
}
}
38 changes: 38 additions & 0 deletions spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package:
name: strings
description: String and char utility functions, regular expressions.
build:
strict: true
pedanticPackages: true
publish:
version: 6.1.0
license: BSD-3-Clause
location:
githubOwner: purescript
githubRepo: purescript-strings
dependencies:
- arrays: ">=7.0.0 <8.0.0"
- control: ">=6.0.0 <7.0.0"
- either: ">=6.0.0 <7.0.0"
- enums: ">=6.0.1 <7.0.0"
- foldable-traversable: ">=6.0.0 <7.0.0"
- gen: ">=4.0.0 <5.0.0"
- integers: ">=6.0.0 <7.0.0"
- maybe: ">=6.0.0 <7.0.0"
- newtype: ">=5.0.0 <6.0.0"
- nonempty: ">=7.0.0 <8.0.0"
- partial: ">=4.0.0 <5.0.0"
- prelude: ">=6.0.0 <7.0.0"
- tailrec: ">=6.0.0 <7.0.0"
- tuples: ">=7.0.0 <8.0.0"
- unfoldable: ">=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"
- console: ">=6.0.0 <7.0.0"
- effect: ">=4.0.0 <5.0.0"
workspace: {}
2 changes: 1 addition & 1 deletion src/Data/Char/Gen.purs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ genDigitChar = toEnumWithDefaults bottom top <$> chooseInt 48 57

-- | Generates a character from the basic latin alphabet.
genAlpha :: forall m. MonadGen m => m Char
genAlpha = oneOf (genAlphaLowercase :| [genAlphaUppercase])
genAlpha = oneOf (genAlphaLowercase :| [ genAlphaUppercase ])

-- | Generates a lowercase character from the basic latin alphabet.
genAlphaLowercase :: forall m. MonadGen m => m Char
Expand Down
22 changes: 12 additions & 10 deletions src/Data/String/CodePoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ var hasCodePointAt = typeof String.prototype.codePointAt === "function";

export const _unsafeCodePointAt0 = function (fallback) {
return hasCodePointAt
? function (str) { return str.codePointAt(0); }
? function (str) {
return str.codePointAt(0);
}
: fallback;
};

Expand All @@ -25,7 +27,7 @@ export const _codePointAt = function (fallback) {
if (index < 0 || index >= length) return Nothing;
if (hasStringIterator) {
var iter = str[Symbol.iterator]();
for (var i = index;; --i) {
for (var i = index; ; --i) {
var o = iter.next();
if (o.done) return Nothing;
if (i === 0) return Just(unsafeCodePointAt0(o.value));
Expand Down Expand Up @@ -61,16 +63,16 @@ export const _countPrefix = function (fallback) {
export const _fromCodePointArray = function (singleton) {
return hasFromCodePoint
? function (cps) {
// Function.prototype.apply will fail for very large second parameters,
// so we don't use it for arrays with 10,000 or more entries.
if (cps.length < 10e3) {
return String.fromCodePoint.apply(String, cps);
// Function.prototype.apply will fail for very large second parameters,
// so we don't use it for arrays with 10,000 or more entries.
if (cps.length < 10e3) {
return String.fromCodePoint.apply(String, cps);
}
return cps.map(singleton).join("");
}
return cps.map(singleton).join("");
}
: function (cps) {
return cps.map(singleton).join("");
};
return cps.map(singleton).join("");
};
};

export const _singleton = function (fallback) {
Expand Down
Loading
Loading