Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
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
    machad0 commented #2771
  • Jan 31 2019 02:26
    JeffreyChan commented #2777
  • Jan 30 2019 14:30
    CrossEye closed #2777
  • Jan 30 2019 12:13
    vanyadymousky updated the wiki
  • Jan 30 2019 01:42
    JeffreyChan commented #2777
  • Jan 29 2019 21:06
    vanyadymousky updated the wiki
  • Jan 29 2019 16:28
    CrossEye commented #2777
  • Jan 29 2019 15:50
    mbostock commented #2772
  • Jan 29 2019 15:48
    CrossEye commented #2772
zhangyd
@zydmayday

I have a question about how to combine multiple functions with compose/pipe,
Is there any possibility to combine funcA and funcB in ramda way?
(or any reason we shouldn't do something like this.

Thanks in advance!

const funcA = (a, b) => a + b;
const funcB = (ab, c) => ab * c;

const funcC = (a, b, c) => {
  const ab = funcA(a, b);
  return funcB(ab, c)
}

funcC(1,2,3) // 9

Below is example using ramda REPL.
https://ramdajs.com/repl/#?const%20funcA%20%3D%20%28a%2C%20b%29%20%3D%3E%20a%20%2B%20b%3B%0Aconst%20funcB%20%3D%20%28ab%2C%20c%29%20%3D%3E%20ab%20%2A%20c%3B%0A%0Aconst%20funcC%20%3D%20%28a%2C%20b%2C%20c%29%20%3D%3E%20%7B%0A%20%20const%20ab%20%3D%20funcA%28a%2C%20b%29%3B%0A%20%20return%20funcB%28ab%2C%20c%29%0A%7D%0A%0AfuncC%281%2C2%2C3%29%20%2F%2F%209

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)])

1 reply
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 ?
1 reply
#!/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
@aviladev

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
@aviladev
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
@aviladev

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
)

REPL: https://tinyurl.com/yzlg72gq

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
@nik_so_twitter
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?
1 reply
KAMi KZ
@kamikz85_twitter
@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
@kamikz85_twitter Ok, thanks!
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;
    link: string
}

interface
```export interface UserData {
    _id: string | undefined;

    files: File[];
}

state example

const state = {
 user: { data: {
    id: 1,
    files : [{id:"1", link: "somelink"}]
  }}
}

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
Good day to all, could you please help me to point-free this one:
// pageBelongsToDocumentWith :: Int -> Page -> Boolean
const pageBelongsToDocumentWith = documentIndex => compose(
  equals(documentIndex),
  prop('documentIndex')
)
wangzengdi
@adispring
@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(
    reject(pipe(values, head, isNilOrEmpty)),
    ... // 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.
2 replies