I wrote a capitalising function using

`ap`

but I’m wondering if there’s a more clever way to do it?`const capitalize = ap(compose(concat, toUpper, head), compose(toLower, tail))`

Well, I wouldn't call this clever:

`const capitalize = pipe(toLower, replace(/^./, toUpper))`

Get ready to LambdUp again!

Reason, ClojureScript, Elm, F#, Elixir. With an emphasis on front-ends. For any dev—from beginner to expert.

FB event: https://www.facebook.com/events/634968546860702/

Website: https://www.lambdup.io/

Reason, ClojureScript, Elm, F#, Elixir. With an emphasis on front-ends. For any dev—from beginner to expert.

FB event: https://www.facebook.com/events/634968546860702/

Website: https://www.lambdup.io/

Hi everyone I am wondering if there is a cleaner way to do this. Thanks

```
const data = [
{a: 1, b: 2, c: 3},
{a: 2, b: 3, c: 4},
{a: 3, b: 4, c: 5},
{a: 4, b: 5, c: 6},
{a: 5, b: 6, c: 7},
{a: 6, b: 7, c: 8},
{a: 7, b: 8, c: 9, d: 10}
]
R.pipe(
R.reduce(R.mergeWith(R.add), {}),
r => R.assoc('grandTotal', R.pipe(R.values, R.sum)(r), r)
)(data)
// Expected
// {a: 28, b: 35, c: 42, dTotal: 10, grandTotal: 115}
```

@lax4mike that example is from the doc website https://ramdajs.com/docs/#chain, I didnt make that up, yes I can read what r.chain does, and yes, I understand why that example works (now)

oh, that is in the docs. I don't understand that

i see this (https://github.com/ramda/ramda/blob/v0.25.0/source/chain.js#L31-L33) but there is no documentation about this behavior in the ramda docs, or in the fantasy land spec

can you explain?

I have no idea, I dont even know what "Maybe" means

is that from a library?

i'm asking about the

`R.chain`

example
ah

ok

yeah, Maybe is an abstract data type from another library

crocs, or folktale, or monet, etc

r.chain( f1, f2)( data )

pseudocode

f1(f2(data),data)

right, i see that in the code, but i don't know why that's a thing

yeah it seems to be a weird thing in the ramda code

if you put in 2 functions it will act like that

i think it has to do with something like that

`Function`

is a monad, but i'm not sure
normally it takes 1 function

ok whats a monad

airity 1?

arity

a monad is an object that has a

`.map`

and `.chain`

method
chapter 9 is about modads

but those videos go right into functors and monads

thanks for the links

must I learn haskell first to fully understand ramda

?

I don't think it's necessary to understand Haskell to understand Ramda. There are some parts of Ramda that rely on knowledge of the `fantasy-land`

spec, which is based in category theory. I think to have a *full* understanding of functions like `chain`

and `traverse`

it's important to understand how the relevant type classes work, but Haskell is just one language that works with those structures.

Understanding `Monads`

, `Functors`

, `Traversables`

, etc. Is really helpful when you want to dig deeper into functional programming in the style that Ramda tends to follow. That being said, there are a ton of useful utilities that don't rely on any of that stuff, and even the tricky functions can be used without understanding the underlying theory.

A good example of that would be stuff like `lenses`

and `transducers`

, which can be immediately helpful to a codebase, but have a deep theoretical basis for them that you don't need to know anything about.

The type signatures are similar to Haskell, but not exactly the same. There's a good article in the wiki that explains them well.