diff --git a/.gitignore b/.gitignore index e12ec5f..880318f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ coverage *.lcov *.log *~ +.idea \ No newline at end of file diff --git a/source/base/misc.js b/source/base/misc.js index 55636f7..5a3298f 100644 --- a/source/base/misc.js +++ b/source/base/misc.js @@ -37,7 +37,7 @@ * multiply(10)(10); // => 100 */ export const partial = (f, ...as) => { - if (as.length === 0) { return f.call(); } + if (!as.length) { return f.call(); } const a = as.shift(); if (a === undefined) { return f; } const p = f.bind(f, a); diff --git a/source/list/building.js b/source/list/building.js index 2d9db67..85690d5 100644 --- a/source/list/building.js +++ b/source/list/building.js @@ -39,7 +39,7 @@ import {error} from '../error'; */ export const scanl = (f, q, ls) => { const scanl_ = (f, q, ls) => { - if (isList(ls) === false) { return error.listError(ls, scanl); } + if (!isList(ls)) { return error.listError(ls, scanl); } if (isEmpty(ls)) { return cons(q)(emptyList); } const x = head(ls); const xs = tail(ls); @@ -63,7 +63,7 @@ export const scanl = (f, q, ls) => { */ export const scanr = (f, q0, as) => { const scanr_ = (f, q0, as) => { - if (isList(as) === false) { return error.listError(as, scanr); } + if (!isList(as)) { return error.listError(as, scanr); } if (isEmpty(as)) { return list(q0); } const x = head(as); const xs = tail(as); diff --git a/source/list/func.js b/source/list/func.js index a9073d0..2893432 100644 --- a/source/list/func.js +++ b/source/list/func.js @@ -172,8 +172,8 @@ export const listFilter = (start, end, filt) => { */ export const listAppend = (xs, ys) => { const listAppend_ = (xs, ys) => { - if (isList(xs) === false ) { return error.listError(xs, listAppend); } - if (isList(ys) === false ) { return error.listError(ys, listAppend); } + if (!isList(xs)) { return error.listError(xs, listAppend); } + if (!isList(ys)) { return error.listError(ys, listAppend); } if (isEmpty(xs)) { return ys; } if (isEmpty(ys)) { return xs; } if (type(head(xs)) === type(head(ys))) { return cons(head(xs))(listAppend(tail(xs))(ys)); } @@ -317,7 +317,7 @@ export const length = xs => { * @returns {boolean} `true` if the object is a `List` and `false` otherwise * @kind function */ -export const isList = a => a instanceof List ? true : false; +export const isList = a => a instanceof List; /** * Check whether a `List` is empty. Returns `true` if the `List` is empty or false if it is diff --git a/source/list/list.js b/source/list/list.js index b744e17..336b17c 100644 --- a/source/list/list.js +++ b/source/list/list.js @@ -80,9 +80,9 @@ export class List extends Type { } // Ord static compare(as, bs) { - if (isEmpty(as) && isEmpty(bs)) { return EQ; } - if (isEmpty(as) && isEmpty(bs) === false) { return LT; } - if (isEmpty(as) === false && isEmpty(bs)) { return GT; } + if (isEmpty(as) && isEmpty(bs)) return EQ; + if (isEmpty(as) && !isEmpty(bs)) return LT; + if (!isEmpty(as) && isEmpty(bs)) return GT; if (compare(head(as), head(bs)) === EQ) { return compare(tail(as), tail(bs)); } return compare(head(as), head(bs)); } diff --git a/source/maybe/func.js b/source/maybe/func.js index 1625406..74ff35c 100644 --- a/source/maybe/func.js +++ b/source/maybe/func.js @@ -44,7 +44,7 @@ export const Nothing = new Maybe(); * @returns {Maybe} `Just a` or `Nothing` * @kind function */ -export const just = a => a === undefined || a === null || a !== a ? Nothing : new Maybe(a); +export const just = a => a == undefined || a !== a ? Nothing : new Maybe(a); /** * Take a default value, a function, and a `Maybe` value. If the `Maybe` value is `Nothing`, return @@ -76,7 +76,7 @@ export const maybe = (n, f, m) => { * @returns {boolean} `true` if the object is a `Maybe` and `false` otherwise * @kind function */ -export const isMaybe = a => a instanceof Maybe ? true : false; +export const isMaybe = a => a instanceof Maybe; /** * Determine whether an object is a `Just`. @@ -87,7 +87,7 @@ export const isMaybe = a => a instanceof Maybe ? true : false; */ export const isJust = m => { if (isMaybe(m) === false) { return error.typeError(m, isJust); } - return isNothing(m) ? false : true; + return !isNothing(m); } /** @@ -99,7 +99,7 @@ export const isJust = m => { */ export const isNothing = m => { if (isMaybe(m) === false) { return error.typeError(m, isNothing); } - return m === Nothing ? true : false; + return m === Nothing; } /** diff --git a/source/type.js b/source/type.js index 4dca8d6..46fbd6b 100644 --- a/source/type.js +++ b/source/type.js @@ -143,8 +143,7 @@ export const typeCheck = (a, b) => { if (a instanceof Type && b instanceof Type) { return dataType(a).type(a) === dataType(b).type(b); } - if (dataType(a) === dataType(b)) { return true; } - return false; - } + return dataType(a) === dataType(b); + }; return partial(typeCheck_, a, b); -} +};