Cool stuff. Haskell is such a pleasure to use.
A few notes:
No arrays in functional JS? Why the heck not?
const head = ([x, ...xs]) => x const tail = ([x, ...xs]) => xs head([1, 2, 3]) // 1 tail([1, 2, 3]) // [2, 3]
I've done plenty of functional js that used the array built-in. Since dynamism is one of JS's strengths, why throw it out?
import { All, Any, mreduceMap, compose, propOr, not, isArray } from 'crocks' const includes = x => xs => isArray(xs) && xs.includes(x) const isAdmin = compose(includes('admin'), propOr([], 'roles')) const areAllAdmins = mreduceMap(All, isAdmin) const noneAreAdmins = not(mreduceMap(Any, isAdmin)) areAllAdmins([ {name: 'Anton', roles: ['author', 'admin']}, {name: 'Ben', roles: ['author', 'founder', 'admin']}, ]) // true noneAreAdmins([ {name: 'Bill', roles: ['author']}, {name: 'Ben', roles: ['author', 'founder', 'admin']}, ]) // false
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Cool stuff. Haskell is such a pleasure to use.
A few notes:
No arrays in functional JS? Why the heck not?
I've done plenty of functional js that used the array built-in. Since dynamism is one of JS's strengths, why throw it out?