@Emilios1995 the

`has`

from lodash fp seems to work fine: `has('request.headers')({request: {headers: {}}}))`

or `has(['request', 'headers'])({request: {headers: {}}}))`

pathSatisfies seems to be made for more complex comparisons.

Right now I'm struggling to create a pure function of this:

```
const def = {
a: 'set-me',
b: {
c: 'use-this-value'
}
};
(def) => {
def.a = def.b.c;
return def;
}
```

Seems simple but I cannot find the right combination.

@rhalff I would use lenses for this.

@Emilios1995 yeah I've tried, but still not sure how to compose it so I get the def back with the updated version.

@rhalff quick example http://goo.gl/1l6l2w

@Emilios1995 thanks, that should work, the only thing I dislike is

`def`

needs to be passed in twice, as in it's not merely flowing through.
@rhalff You can use

`converge`

to help out there.
@ram-bot

```
const def = {
b: {
c: 'use-this-value'
}
}
const fn = converge(assoc('a'), [path(['b', 'c']), identity])
fn(def)
```

`{ b: { c: 'use-this-value' }, a: 'use-this-value' }`

Or (perhaps a little more confusingly) you could use the

`chain`

implementation for functions to remove the use of `identity`

in `converge`

.
@ram-bot

```
const def = {
b: {
c: 'use-this-value'
}
}
const fn = chain(path(['b', 'c']), assoc('a'))
fn(def)
```

`{ b: { c: 'use-this-value' }, a: 'use-this-value' }`

@scott-christopher thanks a lot, both look good, I've neither tried chain or converge yet.

could someone explain to me the correct way to use tryCatch, what I thought was fairly simple from the docs doesn't actually seem to work in the repl. In particular when I load the example I get output that seems wrong.

```
> R.tryCatch(R.prop('x'), R.F, {x: true})
[Function]
```

@scott-christopher I'm still trying to wrap my head around this, I've read everything you guys have said but it still hasn't clicked :)

@scott-christopher what's the

`chain`

implementation for functions?
@scott-christopher Oh I see. It's something like this

Is there a name for this kind of combinator?

`Function.prototype.chain = f => x => this(f(x))(x)`

Is there a name for this kind of combinator?

@ram-bot

`R.tryCatch(R.prop('x'), R.F)({x: true})`

`true`

`R.tryCatch`

@arzig R.tryCatch returns a function that wraps the original function. Because of this, you can't pass in your function arguments to tryCatch, but need to pass them to the function it returns.

JavaScript being JavaScript, it doesn't have any problem with you passing three variables to a function that only takes two though, so your original function you constructed will do the same thing as mine if you pass an object to both of them :-D

If you're familiar with the

`converge`

function, practically you can think of `ap`

and `chain`

over functions like so:```
// f :: a -> b -> c
// g :: a -> b
ap(f, g) = converge(f, [identity, g])
```

```
// f :: b -> a -> c
// g :: a -> b
chain(g, f) = converge(f, [g, identity]);
```

I'm not sure whether there is a named combinator that represents the

`chain`

implementation. (I'm not very familiar with combinatory logic)
@scott-christopher thank you! That is a great example, I'm still not 100% there but I can see the light.

@JAForbes I don't know if this is helpful (let me know if not), but here's the type substitution:

a `Chain`

has to have one free type variable (like `List`

needs to be applied to a type like `String`

to become a type -- a list of strings). The function constructor `(->)`

has two free type variables -- the type it takes in, and the type it produces. If you partially apply the function constructor to its first argument, you end up with a constructor with one free type argument. So, a function from a fixed type `r`

can have `Chain`

(and functor, and applicative ...) implemented for it. So `forall a. r -> a`

is our basis of a chain implementation for functions.

Then we need to define `chain :: (a -> Chain b) -> Chain a -> Chain b`

for our instance of `Chain`

for functions. So we need a function that looks like `chain :: (a -> (r -> b)) -> (r -> a) -> r -> b`

. So we need to end up with a `b`

. We can see a way to do that with an `r`

buried in the first argument -- but we need to give it an `a`

first! Fortunately, we have a way to make an `a`

with an `r`

-- the second argument. So we feed `r`

to the second argument to get the `a`

, then feed the `a`

and the `r`

again to the first argument, and get our `b`

!

hi guys. I'm trying to implement this type of search:

```
[
{name: 'John', age: 28},
{name: 'Jane', age: 26}
]
const find = (searchTerm) => {
return R.filter(
R.compose(
R.any(
R.map((key, value) => {
R.propEq(key, value)
}, searchTerm)
)
), this.data
);
}
// and then something like
var result = find({age: 26});
```

I put this in a separate const find for this example

but this function actually exists within an object

so that's why I have this.data there

but this doesn't work. gives me a weird answer

nevermind :D it's so much simpler..

`return R.filter(R.whereEq(searchTerm));`

that's it..

As I told earlier, we don't need

`converge`

because we have `lift`

and `sequence`

+ `reduce fn`

@rjmk that did help, I think I actually get it now! :) I'm going to try it out in the REPL for a while and let it sink in. But that makes a lot of sense. Thank you

full fp style :smile:

@ram-bot

@ram-bot

`filter(lift(and)(compose(not, modulo(__, 2)), flip(gt)(3)))(range(0, 100))`

@ram-bot

`filter(lift(and)(compose(not, modulo(__, 2)), flip(gt)(3)))(range(0, 100))`

```
[ 4,
6,
8,
10,
12,
14,
16,
18,
20,
22,
24,
26,
28,
30,
32,
34,
36,
38,
40,
42,
44,
46,
48,
50,
52,
54,
56,
58,
60,
62,
64,
66,
68,
70,
72,
74,
76,
78,
80,
82,
84,
86,
88,
90,
92,
94,
96,
98 ]
```

lifting for functions! because function has applicative functor

the same with converge

`filter(converge(and, [compose(not, modulo(__, 2)), flip(gt)(3)]))(range(0, 100))`

because converge also will be created with

`ap`

https://github.com/xgrommx/from-combinators-to-fp/blob/master/src/index.js#L26
`converge = curry((f, fns) => lift(f)(...fns))`

what's the opposite of

`intersection`

?
@Bravilogy maybe

`symmetricDifference`

@Bravilogy or just

`difference`

@xgrommx thank you! symmetric was what I needed

`const listNonCommonProps = (props, item) => R.join(', ', R.symmetricDifference(props, R.keys(item)));`

this stuff is so good

@Bradcomp so do the docs need updating then? Because they suggest its curried with arity of 3.

@xgrommx @scott-christopher are the implemetations of

`ap`

and `chain`

on functions defined in fantasy-land? where do they come from?
@arzig The examples are wrong in the docs. They don't match the description or the type signature. I just looked, and it appears the example has been updated in master: https://github.com/ramda/ramda/blob/master/src/tryCatch.js

For your viewing pleasure here is the second talk I did on FP https://www.youtube.com/watch?v=ZQSU4geXAxM