So there are a couple things you've shown me I need to do. First of I need to update:
These posts assume an understanding of "currying", "partial application" and "function composition". If you feel a bit fuzzy on these topics, there are many resources available on the webs to get you sorted out.
To read more like:
These posts assume an understanding of not only the JavaScript language, but how "currying", "partial application" and "function composition" is accomplished in Javascript....
Also good call on the needing of crocks for the POJ example. I need to break those out into functions like:
// isArray :: a -> BooleanconstisArray=Array.isArray// isString :: a -> BooleanconstisString=x=>typeofx==='string'// isObject :: a -> BooleanconstisObject=x=>!!x&&Object.prototype.toString.call(x)==='[object Object]'
Yeah people should not have to install crocks at this stage in the game.
When the data is an Array with at least one acceptable record, an empty Object will be returned.
How about
Unless the data is an Array with at least one acceptable record, an empty Object will be returned.
Arrays in JS can be of mixed type, so we typically denote that with [ * ], as opposed to something like [ a ] where we expect everything to be that a. Well when our functions can work with mixed typed Arrays. In reality we want to strive for [ a ] or even better something like [ Number ], but sometimes at the edge, we need the [ * ]
You got mostly the compose bits down, except you would just use compose, composeK is for Kleisli arrows ( basically >=> or fish in Haskell). Also you can use either compose or composeK like this:
// x => fn1(fn2(fn3(x)))constfn=compose(fn1,fn2,fn3)
My immediate response is why would I use reduce when I just need to filter.
So this is more than just a filter, we are change types. we move from an Array to an Object. So we want to reduce with {} as our empty on the fold, then only add valid records keyed by their valid id to the accumulator. Does that make sense?
So good.
So there are a couple things you've shown me I need to do. First of I need to update:
To read more like:
Also good call on the needing of
crocks
for the POJ example. I need to break those out into functions like:Yeah people should not have to install crocks at this stage in the game.
How about
Arrays in JS can be of mixed type, so we typically denote that with
[ * ]
, as opposed to something like[ a ]
where we expect everything to be thata
. Well when our functions can work with mixed typedArray
s. In reality we want to strive for[ a ]
or even better something like[ Number ]
, but sometimes at the edge, we need the[ * ]
You got mostly the compose bits down, except you would just use
compose
,composeK
is for Kleisli arrows ( basically>=>
or fish in Haskell). Also you can use eithercompose
orcomposeK
like this:So this is more than just a filter, we are change types. we move from an
Array
to anObject
. So we want to reduce with{}
as our empty on the fold, then only add valid records keyed by their validid
to the accumulator. Does that make sense?Also just to help a fellow Haskeller out here is a quick JS -> Haskell key:
compose
->.
(butcompose
is n-Ary)composeK
->>=>
(butcomposeK
is n-Ary)[type].of
->pure
for Applicative Functor /return
for Monad[instance].chain
->bind
liftA2
->liftA2
converge
-> S' or Phoenix Combinator.I mostly don't know about them. So you are telling me new stuff that I should learn : ))) That's great. Thanks.