Skip to content

Commit fea8f8b

Browse files
committed
-> _
1 parent 096f2ad commit fea8f8b

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

src/either.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Either {
22
constructor(x) {
3-
this.$value = x
3+
this._ = x
44
}
55
}
66

@@ -17,7 +17,7 @@ class Left extends Either {
1717
// ap() { return this }
1818
// ----- Monad (Either a)
1919
// chain() { return this }
20-
// inspect() { return `Left(${this.$value})` }
20+
// inspect() { return `Left(${this._})` }
2121
// ----- Traversable (Either a)
2222
// sequence(of) { return of(this) }
2323
// traverse(of, fn) { return of(this) }
@@ -26,27 +26,27 @@ class Left extends Either {
2626
class Right extends Either {
2727
constructor(x) {
2828
super(x)
29-
this.$value = x
29+
this._ = x
3030
this.isLeft = false
3131
this.isRight = true
3232
// ----- Functor (Either a)
3333
this.map = fn => Either.of(fn(x))
34-
this.join = () => this.$value
34+
this.join = () => this._
3535
}
3636
// ----- Applicative (Either a)
37-
// ap(f) { return f.map(this.$value) }
37+
// ap(f) { return f.map(this._) }
3838
// ----- Monad (Either a)
39-
// chain(fn) { return fn(this.$value) }
40-
// inspect() { return `Right(${this.$value})` }
39+
// chain(fn) { return fn(this._) }
40+
// inspect() { return `Right(${this._})` }
4141
// ----- Traversable (Either a)
4242
// sequence(of) { return this.traverse(of, identity) }
43-
// traverse(of, fn) { fn(this.$value).map(Either.of) }
43+
// traverse(of, fn) { fn(this._).map(Either.of) }
4444
}
4545

4646
// ----- Pointed (Either a)
4747
Either.of = x => new Right(x)
4848

49-
const either = (f, g) => e => (e.isLeft ? f(e.$value) : g(e.$value))
49+
const either = (f, g) => e => (e.isLeft ? f(e._) : g(e._))
5050

5151
module.exports = {
5252
Either,

src/identity.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ class Identity {
66
this.chain = fn => this.map(fn).join()
77
this.join = () => x
88
}
9-
// inspect() { return `Identity(${this.$value})` }
9+
// inspect() { return `Identity(${this._})` }
1010
// ----- Applicative Identity
11-
// ap(f) { return f.map(this.$value) }
11+
// ap(f) { return f.map(this._) }
1212
// ----- Traversable Identity
1313
// sequence(of) { return this.traverse(of, identity) }
14-
// traverse(of, fn) { return fn(this.$value).map(Identity.of) }
14+
// traverse(of, fn) { return fn(this._).map(Identity.of) }
1515
}
1616

1717
// ----- Pointed Identity

src/maybe.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
class Maybe {
22
constructor(x) {
3-
this.$value = x
3+
this._ = x
44
this.nil = x === undefined
55
// ----- Functor Maybe
66
this.map = fn => (this.nil ? this : Maybe.of(fn(x)))
77
this.join = () => (this.nil ? this : x)
88
}
9-
// inspect() { return `Maybe(${this.$value}`; }
9+
// inspect() { return `Maybe(${this._}`; }
1010
// ----- Applicative Maybe
11-
// ap(f) { return this.nil ? this : f.map(this.$value) }
11+
// ap(f) { return this.nil ? this : f.map(this._) }
1212
// ----- Monad Maybe
1313
// chain(fn) { return this.map(fn).join() }
1414
// ----- Traversable Maybe
1515
// sequence(of) { this.traverse(of, identity) }
16-
// traverse(of, fn) { return this.nil ? of(this) : fn(this.$value).map(Maybe.of) }
16+
// traverse(of, fn) { return this.nil ? of(this) : fn(this._).map(Maybe.of) }
1717
}
1818
// ----- Pointed Maybe
1919
Maybe.of = x => new Maybe(x)
2020

21-
const maybe = v => f => m => (m.nil ? v : f(m.$value))
21+
const maybe = v => f => m => (m.nil ? v : f(m._))
2222

2323
module.exports = {
2424
Maybe,

0 commit comments

Comments
 (0)