## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• Jan 31 2019 22:17
CrossEye commented #2779
• Jan 31 2019 21:04
ArturAralin commented #2779
• Jan 31 2019 20:08
CrossEye commented #2779
• Jan 31 2019 18:56
buzzdecafe commented #2631
• Jan 31 2019 18:09
ArturAralin commented #2779
• Jan 31 2019 16:18
CrossEye commented #2779
• Jan 31 2019 16:10
CrossEye commented #2631
• Jan 31 2019 16:06
CrossEye commented #2777
• Jan 31 2019 14:44
ArturAralin opened #2779
• Jan 31 2019 07:39
inferusvv commented #2631
• Jan 31 2019 03:07
sespinozj commented #2771
• Jan 31 2019 02:33
• Jan 31 2019 02:26
JeffreyChan commented #2777
• Jan 30 2019 14:30
CrossEye closed #2777
• Jan 30 2019 12:13
• Jan 30 2019 01:42
JeffreyChan commented #2777
• Jan 29 2019 21:06
• Jan 29 2019 16:28
CrossEye commented #2777
• Jan 29 2019 15:50
mbostock commented #2772
• Jan 29 2019 15:48
CrossEye commented #2772
Andy Mac
@zxol

@zydmayday if we look at funcB we see it's a 2-arity function. Remember that piping or composing functions only works when they're 1-arity or curried. But lets assume funcb is curried, then using compose would work, with one caveat, you have to call it like funcC(1,2)(3). That's because the result of compose is a 2-arity function (the same as funcA) - it'll just just throw away the 3rd argument. This will often work in the context of a larger program, if you're always calling it partially.

You can use a combinator to get around this. in this case it's a (f, g) => (a, b, c) => g(f(a,b), c) I don't think that one has a special name in FPland.

The ramda version of that combinator would be something like converge(funcB, [funcA, nthArg(2)])

zhangyd
@zydmayday
Ken Okabe
@stken2050
Hi, I wonder if ramda developers notice TC39 pipeline-operator is now Stage2 and people are upset against the decision of Hack-style proposal.
5 replies
RxJS author has just announced he considers the Hack proposal is not worth adopting, and will never cooperate with and ignore it.
https://github.com/tc39/proposal-pipeline-operator/issues/228#issuecomment-925465598
Andy Mac
@zxol
I'm thinking about making an atom (ide) package that functions like the ramdajs.com repl. I'd like to include options too, to include other popular FP packages. If anyone has any feature suggestions or is interested in helping, let me know.
Ken Okabe
@stken2050
TC39/proposal-pipeline-operator Hack-style |> hijacks Grouping operator ( ) https://dev.to/stken2050/the-current-tc39-proposal-pipeline-operator-hack-style-hijacks-grouping-operator-1dam Give me comments thanks.
Mike Lambert
@lax4mike
is there another proposal somewhere that would be an alternative to the hack-style proposal?
Mike Lambert
@lax4mike
I'm reading up, looks like the other is the F# style (https://github.com/tc39/proposal-pipeline-operator#why-the-hack-pipe-operator)
Nils Riedemann
@nocksock
As someone, who's just getting into FP... I, well... prefer the hack pipe? :D Much clearer what's happening to me. It might not look as elegant, but I'm hoping that's not the only argument against it?
5 replies
Andreas Herd
@mendrik
This message was deleted
2 replies
Charles Hughes
@chughes87
Does anyone have an SVG of the Ramda logo?
4 replies
mlivi25
@mlivi25
Does ramda have any issues in IE ?
#!/bin/BasH
@bas080

I finished working on an initial version of a pattern matching library and wanted to share it with you guys. Please share your thoughts if you have the time and are interested. Yes this is a bit of a shameless plug, but I don't know of other communities where I can share this.

https://github.com/bas080/patroon

Pedro Ávila

Hi, I'm trying to make this peace of code more functional like, and more elegant, so this:

checkActive(service).then(
isActive => isActive
? stopService(service)
: startService(service)
)

Became this:

checkActive(service).then(
ifElse(
identity,
partial(stopService, [service]),
partial(startService, [service])
)
)

But to me, the first one seems easier to understand. Maybe there's a better approach? Would love any insights on this... thanks!

14 replies
Stefano Vozza
@svozza
frist one is much clearer imo
4 replies
Scott Sauyet
@CrossEye
Yes, that last is quite nice.
Pedro Ávila
Thank you guys!
Ben Carp
@carpben
Hi,
What is the deal with Ramda's tree shaking? Is it similar to Lodash? U need to manually import 'ramda/pick'?
vinodsudini
@vinodsudini
Hi, when can I expect the new version with security fix for Redos ?
ed@sharpertool.com
@kutenai
I am using this const hasRequiredKeys = R.allPass(R.map(R.has, disallowed_keys)) to insure required keys are in an object. I now want to reverse that, and check to insure a set of 'disallowed' keys are NOT in there.
2 replies
Pedro Ávila

I think I found a bug in includes:

const fn = includes(__) (['foo', 'bar'])
const fn2 = includes(__, ['foo', 'bar'])

console.log(
fn('foo'), // false
fn('bar'), // false
fn2('foo'), // true
fn2('bar'), // true
fn2('not present'), // false
)
6 replies
Joshua Travis
@jktravis
Hi. We have several projects that were using lodash. We’ve started introducing Ramda. But now we want to see what it would take to replace lodash completely. My question is, does anyone have a codemod or similar to help facilitate this process?
James Ramm
@JamesRamm

Does ramda have a point-free way to do this:

const callMethod = obj => obj.someMethod;

I could do:

const callMethod = R.compose(R.call, R.prop('someMethod'))

But that does not seem any clearer and certainly less concise. I was thinking perhaps ramda has a builtin fn for it, but I couldn't find it...

Ideally, generically, e.g.:

const callMethod = curry((name, obj)  => obj[name]())
4 replies
nik so
Hello James that method is call invoker
Aron Griffis
@agriffis
The Ramda docs reference the Maybe type, for example for traverse, but it's not part of Ramda that I can tell. Is there an implementation people commonly use?
KAMi KZ
@agriffis so I'd say any ADT libraries that implements the fantasy-land specifications would do the trick. So personally I use folktales, but i think crocks will do the trick, too.
Aron Griffis
@agriffis
Soya
@Soya-xy
Is there a _.get (Object, 'a.b.c', 'default ") like Lodash; method is taken from the string
8 replies
Joshua Travis
@jktravis
No. But you can create your own wrapper for it pretty easily.
Dennie de Lange
@tkvw
is there a better way to do this in typescript? I need to do all kind of type assertions because of nth:
R.pipe(
R.toPairs,
R.filter(R.pipe(
R.nth(1) as (value: [string,string]) => string,
R.both(R.pipe(R.isNil, R.not), R.pipe(R.startsWith('workspace:'), R.not))
) as (v: [string,string]) => boolean),
R.fromPairs
) as (data: Record<string,string>) =>Record<string,string>
Peter Blockman
@peterblockman
This message was deleted

Hi, I am having this problem with TS type. Do you have any idea?

error

No overload matches this call.
The last overload gave the following error.
Argument of type 'concat_list_10<File>' is not assignable to parameter of type 'Morphism<unknown, unknown>'.
Types of parameters 'b' and 'value' are incompatible.
Type 'unknown' is not assignable to type 'unknown[]'.ts(2769)
over.d.ts(106, 5): The last overload is declared here.

The code

const updateFiles =  R.concat(files)
set(state => {
return R.over(lensFiles, updateFiles, state)
})
export interface File {
id: string;
}

interface
export interface UserData {
_id: string | undefined;

files: File[];
}

state example

const state = {
user: { data: {
id: 1,
}}
}

Version

    "ramda": "^0.27.1",
"@types/ramda": "types/npm-ramda#dist",
#!/bin/BasH
@bas080
over(compose(somePathLens, indexIsOdd), add(1))({a: {b: [1,1,1,1]}}) // => {a: {b: {[1,2,1,2]}}
How would I implement a lens that works on a subset of an array. In this case only the items where the index is odd.
klequis
@klequis
For those who are developing JavaScript apps but not using Typescript I'm wondering if you are just writing traditional JS or if you have adopted other techniques or tools that add types or help you manage the absence of types. I'm asking because I really like the benefits of using types but find TypeScript quite verbose. I'm pretty well versed in the issues & possibilities with using Functional Programming and/or Ramda with TypeScript, so not asking bout anything in that direction.
Joshua Travis
@jktravis
[I] don't use any tool for types 'cept JSDoc. Most modern IDEs will give a decent auto-complete based on imports and such by using the TS engine as more of a linter when doing so, but without the extra build step or complexity in the build.
klequis
@klequis
@jktravis Thanks for the tip. I see there is a section in the TS handbook for doing that.
Alexei Kozhushkov
@joystick
// pageBelongsToDocumentWith :: Int -> Page -> Boolean
const pageBelongsToDocumentWith = documentIndex => compose(
equals(documentIndex),
prop('documentIndex')
)
wangzengdi
@joystick
const pageBelongsToDocumentWith = R.useWith(R.identity, R.prop('documentIndex'))
Alexei Kozhushkov
@joystick

@joystick

const pageBelongsToDocumentWith = R.useWith(R.identity, R.prop('documentIndex'))

Magic 😀

3 replies
Daniel
@dbstraight

So how long does it take before ramda and point-free programming stop making you feel dumb because of what you can't figure out? :laughing:

Trying to figure out how to point-free this and just..... can't get my brain around it. It has to be so easy.

f => x => f(x)(x)
2 replies
Djordjenp
@Djordjenp
Can someone tell me what I am doing wrong here?
import {__, curry, add} from "ramda";

const subtractNums = (a,b,c) => a - (b + c);

const subtractCurried = curry(subtractNums);
const func = subtractCurried(__)(5)(6);

console.log(func(15)) // -16
4 replies
Nicolas Ramirez
@kamatheuska
Hi everyone! I am reviewing a PR where the dev is using nested pipes. Just from the looks of it, I think there must be a better solution. Could you give me some feedback on the snippet?:
 const filterFns = pipe(
... // some other code, not important for now
])),
)([...$or, ...$and]);
pathTo and isNilOrEmpty are helpers in our code based on Ramda...
In principle, it seems to be very ugly code, but I am not a functional wizard programmer, so I am no sure how to build an argument or working alternative to it
any ideas?
4 replies
Akira Cai
@blackwindforce
The document just released 0.28.0, some issues found so far
#!/bin/BasH
@bas080
includes(_, [1,2,3]) // => false
_ is indeed not an item in the array. But i expected different behavior similar to flip(includes)`. Mentioning it here because I think this issue has already been raised.