These are chat archives for ramda/ramda

11th
Oct 2016
Ken Aguilar
@piq9117
Oct 11 2016 02:30
 Argument of type '{ [key: string]: any; }' is not assignable to parameter of type 'Functor<any>'.
  Property 'map' is missing in type '{ [key: string]: any; }'
I'm using typescript. how do i fix this error?
typescript cant handle ramda?
sdfereday
@sdfereday
Oct 11 2016 08:08
@piq9117 Should be fine with R, got it running (albeit a simple setup) with TS by just using a declaration. Have you had it working previous to this error? Is your code attempting to assign two different types as if they were they same type? (new at this, so I may be totally off the mark) :P
sdfereday
@sdfereday
Oct 11 2016 08:20
  • had it working with simpler R methods should I say if at all.
Ken Aguilar
@piq9117
Oct 11 2016 09:48
@sdfereday thank you for the response. I refactored and its working nod
*now
sdfereday
@sdfereday
Oct 11 2016 13:52
@piq9117 Ah awesome, good job! Literally just diving in to TypeScript myself so my advice is a little dry
Barry G
@bgits
Oct 11 2016 15:41
If the function being memoized does not use the last param will memoized still check the last param to decide if values should be recomputed? ie: https://dpaste.de/SsLO
if the last param is an object, does memoize do a deep equality check?
Barry G
@bgits
Oct 11 2016 15:47
My guess is yes based on this simple example: https://goo.gl/PzuKt1
Michael Malura
@maluramichael
Oct 11 2016 18:35
Can someone hint me how to reject an array of objects by another array of ids?
var idsToIgnore = [1,2,3];
var data = [{id: 1}, {id:4}]; // i need the result to be [{id: 4}]
LeonineKing1199
@LeonineKing1199
Oct 11 2016 18:40
You can probably use reject(o => contains(o.id, idsToIgnore), data)
* not tested *
Michael Malura
@maluramichael
Oct 11 2016 18:41
Oh nice. I thought of to complicated stuff. Thanks @LeonineKing1199
It is working
LeonineKing1199
@LeonineKing1199
Oct 11 2016 18:43
:)
Michael Malura
@maluramichael
Oct 11 2016 18:55
Is there an 'or' version of allPass?
AnyPass?
Nice this works
const newData = response.data;

const isIgnored = o => R.contains(o.id, this.props.Store.Data.ignored);
const isWatched = o => R.contains(o.id, this.props.Store.Data.watched);
const isOnList = o => R.contains(o.id, R.pluck('id', this.props.Store.Data.data));

const filteredData = R.reject(
    R.anyPass([isIgnored, isWatched, isOnList]),
    newData
);
LeonineKing1199
@LeonineKing1199
Oct 11 2016 19:41
@maluramichael There's also R.where which might be useful as well for generating your predicates.
Denis Stoyanov
@xgrommx
Oct 11 2016 20:20
@maluramichael const isIgnored = R.compose(R.flip(R.contains)(this.props.Store.Data.ignored), prop('id')) pointfree =)
Michael Malura
@maluramichael
Oct 11 2016 20:21
@xgrommx wow now i have to read some documentation :D
Denis Stoyanov
@xgrommx
Oct 11 2016 20:24
@maluramichael also R.useWith(R.contains, [prop('id'), path('props', 'Strore', 'Data', 'ignored')])(o, this)
LeonineKing1199
@LeonineKing1199
Oct 11 2016 20:25
The path call could also probably be part of a defaultTo([])
defaultTo([], path(...))
Denis Stoyanov
@xgrommx
Oct 11 2016 20:28
@LeonineKing1199 it is just details =) I think we need to use lens with Maybe like safeLens =)
LeonineKing1199
@LeonineKing1199
Oct 11 2016 20:28
No pun intended but maybe.
I like the useWith version more than the flip one. I'm not a fan of flip, personally.
Denis Stoyanov
@xgrommx
Oct 11 2016 20:29
@LeonineKing1199 yes, Psi combinator?
LeonineKing1199
@LeonineKing1199
Oct 11 2016 20:31
Oh, that's interesting. I had to google that and got the type signature: psi :: (b -> b -> c) -> (a -> b) -> a -> a -> c
How would that apply here?
Brad Compton (he/him)
@Bradcomp
Oct 11 2016 20:32
is psi Haskell's on operator?
LeonineKing1199
@LeonineKing1199
Oct 11 2016 20:32
Also, one thing I do dig about the Haskell type signature is that you can actually infer what that whole function does just looking at the signature
Denis Stoyanov
@xgrommx
Oct 11 2016 20:32
@LeonineKing1199 in haskell it will be on operator. Also const on = f => g => x => y => useWith(f, [g, g])(x, y)
LeonineKing1199
@LeonineKing1199
Oct 11 2016 20:32
So in this instance, we're just invoking (a->b) twice and then feeding it into (b -> b -> c)
Denis Stoyanov
@xgrommx
Oct 11 2016 20:32
@Bradcomp yes =)
LeonineKing1199
@LeonineKing1199
Oct 11 2016 20:33
Oh, that's funny.
I feel like useWith would violate that though
There's no hard requirement on the a
But that's just because JS just doesn't have types.
Just so long as (... -> b) is preserved
Michael Malura
@maluramichael
Oct 11 2016 20:58
Yeay some success while trying my first baby steps with ramda. Getting the value of one of the provided properties:
var data = [{name: 'x'}, {title: 'y'}, {title: 'z'}];        
const name = R.compose(
  R.head,
  R.values,
  R.pick(['name', 'title'])
); // ['x', 'y', 'z']
data = R.sortBy(name, data);
LeonineKing1199
@LeonineKing1199
Oct 11 2016 21:03
You can probably condense the R.values(R.pick()) into a R.props call, I do believe.
Markus Pfundstein
@MarkusPfundstein
Oct 11 2016 21:04
This message was deleted
Michael Malura
@maluramichael
Oct 11 2016 21:05
Every data element contains more props than just title or name.
LeonineKing1199
@LeonineKing1199
Oct 11 2016 21:09
So? You're doing the same thing R.props would do for you with compose(values, pick([...]))