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
31 changes: 9 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/.*
!/.gitignore
!/.github/
!/.tidyrc.json
/bower_components/
/node_modules/
/output/
package-lock.json
/package-lock.json
/spago.lock
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: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
24 changes: 0 additions & 24 deletions bower.json

This file was deleted.

15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
18 changes: 18 additions & 0 deletions spago.yaml
Original file line number Diff line number Diff line change
@@ -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: {}
23 changes: 12 additions & 11 deletions src/Data/Maybe.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
-- |
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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) _

Expand Down
3 changes: 1 addition & 2 deletions src/Data/Maybe/First.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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(..))
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/Data/Maybe/Last.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading