diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c69237a..811ea7f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,30 +6,17 @@ 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 run format:check diff --git a/.gitignore b/.gitignore index 7ebd961..c9c5856 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ /.* !/.gitignore !/.github/ +!/.tidyrc.json /bower_components/ /node_modules/ /output/ -package-lock.json +/package-lock.json +/spago.lock diff --git a/.tidyrc.json b/.tidyrc.json new file mode 100644 index 0000000..9e39cf1 --- /dev/null +++ b/.tidyrc.json @@ -0,0 +1,10 @@ +{ + "importSort": "ide", + "importWrap": "source", + "indent": 2, + "operatorsFile": null, + "ribbon": 1, + "typeArrowPlacement": "first", + "unicode": "never", + "width": null +} diff --git a/CHANGELOG.md b/CHANGELOG.md index fb717fc..d517502 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,13 +12,27 @@ Bugfixes: Other improvements: +## [v6.0.1](https://github.com/purescript/purescript-maybe/releases/tag/v6.0.1) - 2026-10-17 + +Breaking changes: + +New features: + +Bugfixes: + +Other improvements: + +- Migrate from Bower/Pulp to Spago and update CI and formatting (#65 by @thomashoneyman) + ## [v6.0.0](https://github.com/purescript/purescript-maybe/releases/tag/v6.0.0) - 2022-04-27 Breaking changes: + - Update project and deps to PureScript v0.15.0 (#60 by @JordanMartinez) - Drop deprecated `MonadZero` instance (#61 by @JordanMartinez) New features: + - Added `Semiring` instance (#59) Bugfixes: @@ -28,15 +42,18 @@ Other improvements: ## [v5.0.0](https://github.com/purescript/purescript-maybe/releases/tag/v5.0.0) - 2021-02-26 Breaking changes: + - Added support for PureScript 0.14 and dropped support for all previous versions (#50) - Ported the `generics-rep` package's `Maybe` instance to this package (#55) New features: Bugfixes: + - Relaxed constraints on `optional`, which doesn't need the `Plus` part of `Alternative` (#47) Other improvements: + - Fixed documentation comment for the `Last` newtype, which omitted the constructor (#42) - Documented the relationship of `optional` to the left catch law (#52) - Demonstrated how `do` notation for `Maybe` is similar to nested if-then-else statements (#48) @@ -80,8 +97,9 @@ Other improvements: ## [v1.0.0](https://github.com/purescript/purescript-maybe/releases/tag/v1.0.0) - 2016-06-01 - Updated for PureScript 0.9.1 - + This release is intended for the PureScript 0.9.1 compiler and newer. **Note**: The v1.0.0 tag is not meant to indicate the library is “finished”, the core libraries are all being bumped to this for the 0.9 compiler release so as to use semver more correctly. + - Updated for new `Prelude` class hierarchies ## [v0.3.5](https://github.com/purescript/purescript-maybe/releases/tag/v0.3.5) - 2015-11-15 @@ -137,3 +155,5 @@ Other improvements: ## [v0.1.0](https://github.com/purescript/purescript-maybe/releases/tag/v0.1.0) - 2014-04-10 - Initial versioned release + +[Unreleased]: https://github.com/purescript/purescript-maybe/compare/v6.0.1...HEAD diff --git a/bower.json b/bower.json deleted file mode 100644 index a2ab363..0000000 --- a/bower.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "purescript-maybe", - "homepage": "https://github.com/purescript/purescript-maybe", - "license": "BSD-3-Clause", - "repository": { - "type": "git", - "url": "https://github.com/purescript/purescript-maybe.git" - }, - "ignore": [ - "**/.*", - "bower_components", - "node_modules", - "output", - "test", - "bower.json", - "package.json" - ], - "dependencies": { - "purescript-control": "^6.0.0", - "purescript-invariant": "^6.0.0", - "purescript-newtype": "^5.0.0", - "purescript-prelude": "^6.0.0" - } -} diff --git a/package.json b/package.json index 3e28704..8a28612 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,17 @@ { "private": true, + "homepage": "https://github.com/purescript/purescript-maybe", + "license": "BSD-3-Clause", + "repository": "github:purescript/purescript-maybe", "scripts": { - "clean": "rimraf output && rimraf .pulp-cache", - "build": "pulp build -- --censor-lib --strict" + "build": "spago build", + "format": "purs-tidy format-in-place src && oxfmt --write .", + "format:check": "purs-tidy check src && oxfmt --check ." }, "devDependencies": { - "pulp": "16.0.0-0", - "purescript-psa": "^0.8.2", - "rimraf": "^3.0.2" + "oxfmt": "^0.73.0", + "purescript": "^0.15.16", + "purs-tidy": "^0.11.1", + "spago": "^1.0.5" } } diff --git a/spago.yaml b/spago.yaml new file mode 100644 index 0000000..5e42b8f --- /dev/null +++ b/spago.yaml @@ -0,0 +1,18 @@ +package: + name: maybe + description: Optional values + build: + strict: true + pedanticPackages: true + publish: + version: 6.0.1 + license: BSD-3-Clause + location: + githubOwner: purescript + githubRepo: purescript-maybe + dependencies: + - control: ">=6.0.0 <7.0.0" + - invariant: ">=6.0.0 <7.0.0" + - newtype: ">=5.0.0 <6.0.0" + - prelude: ">=6.0.0 <7.0.0" +workspace: {} diff --git a/src/Data/Maybe.purs b/src/Data/Maybe.purs index 743279b..60fcccd 100644 --- a/src/Data/Maybe.purs +++ b/src/Data/Maybe.purs @@ -6,7 +6,6 @@ import Control.Alt (class Alt, (<|>)) import Control.Alternative (class Alternative) import Control.Extend (class Extend) import Control.Plus (class Plus) - import Data.Eq (class Eq1) import Data.Functor.Invariant (class Invariant, imapF) import Data.Generic.Rep (class Generic) @@ -31,7 +30,7 @@ data Maybe a = Nothing | Just a -- | ``` instance functorMaybe :: Functor Maybe where map fn (Just x) = Just (fn x) - map _ _ = Nothing + map _ _ = Nothing -- | The `Apply` instance allows functions contained within a `Just` to -- | transform a value contained within a `Just` using the `apply` operator: @@ -66,13 +65,13 @@ instance functorMaybe :: Functor Maybe where -- | ``` instance applyMaybe :: Apply Maybe where apply (Just fn) x = fn <$> x - apply Nothing _ = Nothing + apply Nothing _ = Nothing -- | The `Applicative` instance enables lifting of values into `Maybe` with the -- | `pure` function: -- | -- | ``` purescript --- | pure x :: Maybe _ == Just x +-- | (pure x :: Maybe _) == Just x -- | ``` -- | -- | Combining `Functor`'s `<$>` with `Apply`'s `<*>` and `Applicative`'s @@ -101,7 +100,7 @@ instance applicativeMaybe :: Applicative Maybe where -- | ``` instance altMaybe :: Alt Maybe where alt Nothing r = r - alt l _ = l + alt l _ = l -- | The `Plus` instance provides a default `Maybe` value: -- | @@ -124,7 +123,7 @@ instance alternativeMaybe :: Alternative Maybe -- | ``` instance bindMaybe :: Bind Maybe where bind (Just x) k = k x - bind Nothing _ = Nothing + bind Nothing _ = Nothing -- | The `Monad` instance guarantees that there are both `Applicative` and -- | `Bind` instances for `Maybe`. This also enables the `do` syntactic sugar: @@ -162,8 +161,8 @@ instance monadMaybe :: Monad Maybe -- | f <<= x = Just (f x) -- | ``` instance extendMaybe :: Extend Maybe where - extend _ Nothing = Nothing - extend f x = Just (f x) + extend _ Nothing = Nothing + extend f x = Just (f x) instance invariantMaybe :: Invariant Maybe where imap = imapF @@ -202,7 +201,8 @@ instance semiringMaybe :: Semiring a => Semiring (Maybe a) where -- | type the `Maybe` contains. derive instance eqMaybe :: Eq a => Eq (Maybe a) -instance eq1Maybe :: Eq1 Maybe where eq1 = eq +instance eq1Maybe :: Eq1 Maybe where + eq1 = eq -- | The `Ord` instance allows `Maybe` values to be compared with -- | `compare`, `>`, `>=`, `<` and `<=` whenever there is an `Ord` instance for @@ -211,7 +211,8 @@ instance eq1Maybe :: Eq1 Maybe where eq1 = eq -- | `Nothing` is considered to be less than any `Just` value. derive instance ordMaybe :: Ord a => Ord (Maybe a) -instance ord1Maybe :: Ord1 Maybe where compare1 = compare +instance ord1Maybe :: Ord1 Maybe where + compare1 = compare instance boundedMaybe :: Bounded a => Bounded (Maybe a) where top = Just top @@ -222,7 +223,7 @@ instance boundedMaybe :: Bounded a => Bounded (Maybe a) where -- | contains. instance showMaybe :: Show a => Show (Maybe a) where show (Just x) = "(Just " <> show x <> ")" - show Nothing = "Nothing" + show Nothing = "Nothing" derive instance genericMaybe :: Generic (Maybe a) _ diff --git a/src/Data/Maybe/First.purs b/src/Data/Maybe/First.purs index 2641c5c..d0ff551 100644 --- a/src/Data/Maybe/First.purs +++ b/src/Data/Maybe/First.purs @@ -6,7 +6,6 @@ import Control.Alt (class Alt) import Control.Alternative (class Alternative) import Control.Extend (class Extend) import Control.Plus (class Plus) - import Data.Eq (class Eq1) import Data.Functor.Invariant (class Invariant) import Data.Maybe (Maybe(..)) @@ -19,7 +18,7 @@ import Data.Ord (class Ord1) -- | First (Just x) <> First (Just y) == First (Just x) -- | First Nothing <> First (Just y) == First (Just y) -- | First Nothing <> First Nothing == First Nothing --- | mempty :: First _ == First Nothing +-- | (mempty :: First _) == First Nothing -- | ``` newtype First a = First (Maybe a) diff --git a/src/Data/Maybe/Last.purs b/src/Data/Maybe/Last.purs index b70502c..2215256 100644 --- a/src/Data/Maybe/Last.purs +++ b/src/Data/Maybe/Last.purs @@ -18,7 +18,7 @@ import Data.Ord (class Ord1) -- | Last (Just x) <> Last (Just y) == Last (Just y) -- | Last (Just x) <> Last Nothing == Last (Just x) -- | Last Nothing <> Last Nothing == Last Nothing --- | mempty :: Last _ == Last Nothing +-- | (mempty :: Last _) == Last Nothing -- | ``` newtype Last a = Last (Maybe a)