diff --git a/src/algebra/io.js b/src/algebra/io.js index 460dbde..47cfb7a 100644 --- a/src/algebra/io.js +++ b/src/algebra/io.js @@ -55,5 +55,9 @@ export class IO extends Algebra(Monad) { run() { return this._effect() } + + toString() { + return `IO(${this._effect})` + } } diff --git a/src/algebra/list.js b/src/algebra/list.js index b2dd033..95dbda5 100644 --- a/src/algebra/list.js +++ b/src/algebra/list.js @@ -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 { diff --git a/src/algebra/option.js b/src/algebra/option.js index 7ebf79c..ffb6b58 100644 --- a/src/algebra/option.js +++ b/src/algebra/option.js @@ -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' + } } /** diff --git a/src/algebra/result.js b/src/algebra/result.js index 1445f3b..f9fcfc2 100644 --- a/src/algebra/result.js +++ b/src/algebra/result.js @@ -140,6 +140,10 @@ export class Ok extends Interfaces { bimap(f, _g) { return /** @type {Result} */ (this.map(f)) } + + toString() { + return `Ok(${this.#value})` + } } /** @@ -257,6 +261,10 @@ export class Err extends Interfaces { bimap(_f, g) { return /** @type {Result} */ (err(g(this.#value))) } + + toString() { + return `Err(${this.#value})` + } } /**