11class 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 {
2626class 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)
4747Either . 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
5151module . exports = {
5252 Either,
0 commit comments