Compare commits

..

No commits in common. "48df37e502146b4a46225c3193a1c88b7c42cb5d" and "a18a759db4332a834ee5cfff113958ad006779a3" have entirely different histories.

3 changed files with 21 additions and 12 deletions

View file

@ -19,8 +19,5 @@ result.bind(() => Err(new Error(-Infinity)))
.bind(Ok)
result.isErr() // true
// crimes!
None == None() // true
```

View file

@ -81,12 +81,13 @@ function isSome() {
* @returns {this is None}
*/
function isNone() {
return this === None
return this === none
}
/**
* @template T
* @param {?T} value
* @variation 2
* @returns {Some<T>}
*/
export const Some = value => ({
@ -100,13 +101,21 @@ export const Some = value => ({
fold
})
export const None = () => None
None.isSome = isSome
None.isNone = isNone
None.chain = constant
None.map = constant
None.alt = alt
None.fold = fold
/**
* @returns {None}
*/
export const None = () => none
/** @type {None} */
export const none = ({
isSome,
isNone,
chain: constant,
map: constant,
alt,
fold
})
/**
* @template T

View file

@ -1,2 +1,5 @@
export * from './algebra/index.js'
import { Result } from './algebra/result.js'
const a = Result.of(2).chain(x => Result.zero())
console.log(a)