finish refactor
This commit is contained in:
parent
17a10b92f2
commit
d661524857
4 changed files with 28 additions and 0 deletions
|
@ -55,5 +55,9 @@ export class IO extends Algebra(Monad) {
|
|||
run() {
|
||||
return this._effect()
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `IO(${this._effect})`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,10 @@ class Empty extends Interfaces {
|
|||
isEmpty() {
|
||||
return true
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `List(Empty)`
|
||||
}
|
||||
}
|
||||
|
||||
/** @template T */
|
||||
|
@ -172,6 +176,10 @@ class Element extends Interfaces {
|
|||
[]
|
||||
)
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `List(${this.toArray()})`
|
||||
}
|
||||
}
|
||||
|
||||
class TypeRef {
|
||||
|
|
|
@ -85,6 +85,10 @@ export class Some extends Interfaces {
|
|||
reduce(f, init) {
|
||||
return f(init, this.#value)
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `Some(${this.#value})`
|
||||
}
|
||||
}
|
||||
|
||||
/** @template T */
|
||||
|
@ -151,6 +155,10 @@ export class None extends Interfaces {
|
|||
reduce(_f, init) {
|
||||
return init
|
||||
}
|
||||
|
||||
toString() {
|
||||
return 'None'
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -140,6 +140,10 @@ export class Ok extends Interfaces {
|
|||
bimap(f, _g) {
|
||||
return /** @type {Result<T2, E2>} */ (this.map(f))
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `Ok(${this.#value})`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,6 +261,10 @@ export class Err extends Interfaces {
|
|||
bimap(_f, g) {
|
||||
return /** @type {Result<T2, E2>} */ (err(g(this.#value)))
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `Err(${this.#value})`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue