Skip to content

Commit

Permalink
Version 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchambers committed Nov 3, 2019
1 parent ca0ea2b commit 3c5a7f6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 41 deletions.
70 changes: 30 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ either Nothing (the empty value) or a Just whose value is of type `a`.
```javascript
> const Useless = require ('sanctuary-useless')

> const isTypeClass = x =>
. type (x) === 'sanctuary-type-classes/TypeClass@1'

> S.map (k => k + ' '.repeat (16 - k.length) +
. (Z[k].test (Just (Useless)) ? '\u2705 ' :
. Z[k].test (Nothing) ? '\u2705 * ' :
. /* otherwise */ '\u274C '))
. (S.keys (S.unchecked.filter (S.is ($.TypeClass)) (Z)))
. (S.keys (S.unchecked.filter (isTypeClass) (Z)))
[ 'Setoid ✅ * ', // if ‘a’ satisfies Setoid
. 'Ord ✅ * ', // if ‘a’ satisfies Ord
. 'Semigroupoid ❌ ',
Expand All @@ -41,11 +44,11 @@ either Nothing (the empty value) or a Just whose value is of type `a`.
. 'Contravariant ❌ ' ]
```

#### <a name="Maybe" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L144">`Maybe :: TypeRep Maybe`</a>
#### <a name="Maybe" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L147">`Maybe :: TypeRep Maybe`</a>

Maybe [type representative][].

#### <a name="Maybe.Nothing" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L148">`Maybe.Nothing :: Maybe a`</a>
#### <a name="Maybe.Nothing" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L151">`Maybe.Nothing :: Maybe a`</a>

The empty value of type `Maybe a`.

Expand All @@ -54,7 +57,7 @@ The empty value of type `Maybe a`.
Nothing
```

#### <a name="Maybe.Just" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L158">`Maybe.Just :: a -⁠> Maybe a`</a>
#### <a name="Maybe.Just" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L161">`Maybe.Just :: a -⁠> Maybe a`</a>

Constructs a value of type `Maybe a` from a value of type `a`.

Expand All @@ -63,19 +66,7 @@ Constructs a value of type `Maybe a` from a value of type `a`.
Just (42)
```

#### <a name="Maybe.@@type" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L181">`Maybe.@@type :: String`</a>

Maybe [type identifier][].

```javascript
> type (Just (42))
'sanctuary-maybe/Maybe@1'

> type.parse (type (Just (42)))
{namespace: 'sanctuary-maybe', name: 'Maybe', version: 1}
```

#### <a name="Maybe.fantasy-land/empty" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L194">`Maybe.fantasy-land/empty :: () -⁠> Maybe a`</a>
#### <a name="Maybe.fantasy-land/empty" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L184">`Maybe.fantasy-land/empty :: () -⁠> Maybe a`</a>

- `empty (Maybe)` is equivalent to `Nothing`

Expand All @@ -84,7 +75,7 @@ Maybe [type identifier][].
Nothing
```

#### <a name="Maybe.fantasy-land/of" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L204">`Maybe.fantasy-land/of :: a -⁠> Maybe a`</a>
#### <a name="Maybe.fantasy-land/of" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L194">`Maybe.fantasy-land/of :: a -⁠> Maybe a`</a>

- `of (Maybe) (x)` is equivalent to `Just (x)`

Expand All @@ -93,7 +84,7 @@ Nothing
Just (42)
```

#### <a name="Maybe.fantasy-land/chainRec" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L217">`Maybe.fantasy-land/chainRec :: ((a -⁠> c, b -⁠> c, a) -⁠> Maybe c, a) -⁠> Maybe b`</a>
#### <a name="Maybe.fantasy-land/chainRec" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L207">`Maybe.fantasy-land/chainRec :: ((a -⁠> c, b -⁠> c, a) -⁠> Maybe c, a) -⁠> Maybe b`</a>

```javascript
> Z.chainRec (
Expand All @@ -113,7 +104,7 @@ Nothing
Just (65536)
```

#### <a name="Maybe.fantasy-land/zero" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L246">`Maybe.fantasy-land/zero :: () -⁠> Maybe a`</a>
#### <a name="Maybe.fantasy-land/zero" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L236">`Maybe.fantasy-land/zero :: () -⁠> Maybe a`</a>

- `zero (Maybe)` is equivalent to `Nothing`

Expand All @@ -122,7 +113,7 @@ Just (65536)
Nothing
```

#### <a name="Maybe.prototype.@@show" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L256">`Maybe#@@show :: Showable a => Maybe a ~> () -⁠> String`</a>
#### <a name="Maybe.prototype.@@show" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L246">`Maybe#@@show :: Showable a => Maybe a ~> () -⁠> String`</a>

- `show (Nothing)` is equivalent to `'Nothing'`
- `show (Just (x))` is equivalent to `'Just (' + show (x) + ')'`
Expand All @@ -135,7 +126,7 @@ Nothing
'Just (["foo", "bar", "baz"])'
```

#### <a name="Maybe.prototype.fantasy-land/equals" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L275">`Maybe#fantasy-land/equals :: Setoid a => Maybe a ~> Maybe a -⁠> Boolean`</a>
#### <a name="Maybe.prototype.fantasy-land/equals" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L265">`Maybe#fantasy-land/equals :: Setoid a => Maybe a ~> Maybe a -⁠> Boolean`</a>

- `Nothing` is equal to `Nothing`
- `Just (x)` is equal to `Just (y)` [iff][] `x` is equal to `y`
Expand All @@ -156,7 +147,7 @@ false
false
```

#### <a name="Maybe.prototype.fantasy-land/lte" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L302">`Maybe#fantasy-land/lte :: Ord a => Maybe a ~> Maybe a -⁠> Boolean`</a>
#### <a name="Maybe.prototype.fantasy-land/lte" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L292">`Maybe#fantasy-land/lte :: Ord a => Maybe a ~> Maybe a -⁠> Boolean`</a>

- `Nothing` is (less than or) equal to `Nothing`
- `Just (x)` is less than or equal to `Just (y)` [iff][] `x` is less
Expand All @@ -171,7 +162,7 @@ false
[Nothing, Just (0), Just (1)]
```

#### <a name="Maybe.prototype.fantasy-land/concat" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L323">`Maybe#fantasy-land/concat :: Semigroup a => Maybe a ~> Maybe a -⁠> Maybe a`</a>
#### <a name="Maybe.prototype.fantasy-land/concat" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L313">`Maybe#fantasy-land/concat :: Semigroup a => Maybe a ~> Maybe a -⁠> Maybe a`</a>

- `concat (Nothing) (Nothing)` is equivalent to `Nothing`
- `concat (Just (x)) (Just (y))` is equivalent to
Expand All @@ -193,7 +184,7 @@ Just ([1, 2, 3])
Just ([1, 2, 3])
```

#### <a name="Maybe.prototype.fantasy-land/filter" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L351">`Maybe#fantasy-land/filter :: Maybe a ~> (a -⁠> Boolean) -⁠> Maybe a`</a>
#### <a name="Maybe.prototype.fantasy-land/filter" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L341">`Maybe#fantasy-land/filter :: Maybe a ~> (a -⁠> Boolean) -⁠> Maybe a`</a>

- `filter (p) (Nothing)` is equivalent to `Nothing`
- `filter (p) (Just (x))` is equivalent to `p (x) ? Just (x) : Nothing`
Expand All @@ -209,7 +200,7 @@ Nothing
Just (9007199254740991)
```

#### <a name="Maybe.prototype.fantasy-land/map" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L373">`Maybe#fantasy-land/map :: Maybe a ~> (a -⁠> b) -⁠> Maybe b`</a>
#### <a name="Maybe.prototype.fantasy-land/map" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L363">`Maybe#fantasy-land/map :: Maybe a ~> (a -⁠> b) -⁠> Maybe b`</a>

- `map (f) (Nothing)` is equivalent to `Nothing`
- `map (f) (Just (x))` is equivalent to `Just (f (x))`
Expand All @@ -222,7 +213,7 @@ Nothing
Just (3)
```

#### <a name="Maybe.prototype.fantasy-land/ap" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L392">`Maybe#fantasy-land/ap :: Maybe a ~> Maybe (a -⁠> b) -⁠> Maybe b`</a>
#### <a name="Maybe.prototype.fantasy-land/ap" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L382">`Maybe#fantasy-land/ap :: Maybe a ~> Maybe (a -⁠> b) -⁠> Maybe b`</a>

- `ap (Nothing) (Nothing)` is equivalent to `Nothing`
- `ap (Nothing) (Just (x))` is equivalent to `Nothing`
Expand All @@ -243,7 +234,7 @@ Nothing
Just (3)
```

#### <a name="Maybe.prototype.fantasy-land/chain" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L419">`Maybe#fantasy-land/chain :: Maybe a ~> (a -⁠> Maybe b) -⁠> Maybe b`</a>
#### <a name="Maybe.prototype.fantasy-land/chain" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L409">`Maybe#fantasy-land/chain :: Maybe a ~> (a -⁠> Maybe b) -⁠> Maybe b`</a>

- `chain (f) (Nothing)` is equivalent to `Nothing`
- `chain (f) (Just (x))` is equivalent to `f (x)`
Expand All @@ -261,28 +252,28 @@ Nothing
Just ('foo')
```

#### <a name="Maybe.prototype.fantasy-land/alt" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L443">`Maybe#fantasy-land/alt :: Maybe a ~> Maybe a -⁠> Maybe a`</a>
#### <a name="Maybe.prototype.fantasy-land/alt" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L433">`Maybe#fantasy-land/alt :: Maybe a ~> Maybe a -⁠> Maybe a`</a>

- `alt (Nothing) (Nothing)` is equivalent to `Nothing`
- `alt (Nothing) (Just (x))` is equivalent to `Just (x)`
- `alt (Just (x)) (Nothing)` is equivalent to `Just (x)`
- `alt (Just (x)) (Just (y))` is equivalent to `Just (x)`
- `alt (Nothing) (Just (x))` is equivalent to `Just (x)`
- `alt (Just (y)) (Just (x))` is equivalent to `Just (x)`

```javascript
> S.alt (Nothing) (Nothing)
Nothing

> S.alt (Nothing) (Just (1))
> S.alt (Just (1)) (Nothing)
Just (1)

> S.alt (Just (2)) (Nothing)
> S.alt (Nothing) (Just (2))
Just (2)

> S.alt (Just (3)) (Just (4))
> S.alt (Just (4)) (Just (3))
Just (3)
```

#### <a name="Maybe.prototype.fantasy-land/reduce" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L470">`Maybe#fantasy-land/reduce :: Maybe a ~> ((b, a) -⁠> b, b) -⁠> b`</a>
#### <a name="Maybe.prototype.fantasy-land/reduce" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L460">`Maybe#fantasy-land/reduce :: Maybe a ~> ((b, a) -⁠> b, b) -⁠> b`</a>

- `reduce (f) (x) (Nothing)` is equivalent to `x`
- `reduce (f) (x) (Just (y))` is equivalent to `f (x) (y)`
Expand All @@ -295,7 +286,7 @@ Just (3)
'abcxyz'
```

#### <a name="Maybe.prototype.fantasy-land/traverse" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L489">`Maybe#fantasy-land/traverse :: Applicative f => Maybe a ~> (TypeRep f, a -⁠> f b) -⁠> f (Maybe b)`</a>
#### <a name="Maybe.prototype.fantasy-land/traverse" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L479">`Maybe#fantasy-land/traverse :: Applicative f => Maybe a ~> (TypeRep f, a -⁠> f b) -⁠> f (Maybe b)`</a>

- `traverse (A) (f) (Nothing)` is equivalent to `of (A) (Nothing)`
- `traverse (A) (f) (Just (x))` is equivalent to `map (Just) (f (x))`
Expand All @@ -308,7 +299,7 @@ Just (3)
[Just ('foo'), Just ('bar'), Just ('baz')]
```

#### <a name="Maybe.prototype.fantasy-land/extend" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v1.2.0/index.js#L508">`Maybe#fantasy-land/extend :: Maybe a ~> (Maybe a -⁠> b) -⁠> Maybe b`</a>
#### <a name="Maybe.prototype.fantasy-land/extend" href="https://github.com/sanctuary-js/sanctuary-maybe/blob/v2.0.0/index.js#L498">`Maybe#fantasy-land/extend :: Maybe a ~> (Maybe a -⁠> b) -⁠> Maybe b`</a>

- `extend (f) (Nothing)` is equivalent to `Nothing`
- `extend (f) (Just (x))` is equivalent to `Just (f (Just (x)))`
Expand All @@ -322,8 +313,7 @@ Just (100)
```

[Fantasy Land]: https://github.com/fantasyland/fantasy-land/tree/v4.0.1
[`Z.equals`]: https://github.com/sanctuary-js/sanctuary-type-classes/tree/v11.0.0#equals
[`Z.lte`]: https://github.com/sanctuary-js/sanctuary-type-classes/tree/v11.0.0#lte
[`Z.equals`]: https://github.com/sanctuary-js/sanctuary-type-classes/tree/v12.0.0#equals
[`Z.lte`]: https://github.com/sanctuary-js/sanctuary-type-classes/tree/v12.0.0#lte
[iff]: https://en.wikipedia.org/wiki/If_and_only_if
[type identifier]: https://github.com/sanctuary-js/sanctuary-type-identifiers/tree/v2.0.1
[type representative]: https://github.com/fantasyland/fantasy-land/tree/v4.0.1#type-representatives
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sanctuary-maybe",
"version": "1.2.0",
"version": "2.0.0",
"description": "Fantasy Land -compliant Maybe type",
"license": "MIT",
"repository": {
Expand Down

0 comments on commit 3c5a7f6

Please sign in to comment.