These are chat archives for ramda/ramda

8th
Apr 2016
Drew
@dtipson
Apr 08 2016 01:04
@mrtnbroder ah yeah, I didn't consider the partialRight option, thanks
Julien Goux
@jgoux
Apr 08 2016 06:24
ok makes sense @davidchambers !
What are your throughts about : https://github.com/DrBoolean/freeky#synopsis
The do notation using generators reduces the boilerplate a lot, and is elegant !
is there any change to integrate it in fantasyland ?
apparently @Risto-Stevcev already worked on it :D https://github.com/Risto-Stevcev/do-notation
@Risto-Stevcev Do you use it in your code ?
Julien Goux
@jgoux
Apr 08 2016 07:56
The generator approach is really nice, but how do you work with failure ?
Risto Stevcev
@Risto-Stevcev
Apr 08 2016 08:28
@jgoux I use it when it makes the code easier to read, but I often just use pipeK
Someone apparently already made a do notation before me: https://www.npmjs.com/package/fantasydo
His implementation is more or less the same as mine, except his asks for a monad along with the generator function, and you have to return the last monad. Mine works more like the Haskell do.
Also, he implemented this weird thing called Multi mode, which feels a little bit overengineered for me. I can see rerunning the generator for each branch to cause some unexpected things to nondeterministic monads, and it's not that unreadable to just chain those monads
Julien Goux
@jgoux
Apr 08 2016 08:33
@Risto-Stevcev ok
Risto Stevcev
@Risto-Stevcev
Apr 08 2016 08:34
@ram-bot R.chain(c => [c + 1, c + 2], [1, 2])
ram-bot
@ram-bot
Apr 08 2016 08:34
[ 2, 3, 3, 4 ]
Julien Goux
@jgoux
Apr 08 2016 08:34
I made my own as a helper to test it for now
Risto Stevcev
@Risto-Stevcev
Apr 08 2016 08:34
Yeah it's trivial to just roll your own
Julien Goux
@jgoux
Apr 08 2016 08:34
but I do like the fact of passing a monad.of as second argument
Risto Stevcev
@Risto-Stevcev
Apr 08 2016 08:34
Whatever works
Julien Goux
@jgoux
Apr 08 2016 08:35
The best would be to add a do static helper into each monad implementation :p
Risto Stevcev
@Risto-Stevcev
Apr 08 2016 08:35
JS gets a lot of churn, which can be bad at times. But it also gives devs a lot of choice :)
Risto Stevcev
@Risto-Stevcev
Apr 08 2016 08:55
I think I was supposed to add error handling but I guess I forgot to, you would probably have to wrap things in a try/catch, or roll your own implementation
Julien Goux
@jgoux
Apr 08 2016 09:24
@Risto-Stevcev actually I just use S.pipe with function composition to handle failure workflow, and I yield the result ^^
example :
  const demandesEditables = yield S.pipe([
    getDemandesEditables(R.__, patientNumero, patientDateDeNaissance),
    H.finally(S.K(DB.release(dbConnection)))
  ], env)
Risto Stevcev
@Risto-Stevcev
Apr 08 2016 10:59
nice
what's H defined as?
Denis Stoyanov
@xgrommx
Apr 08 2016 11:37
chain is flatMap? flatMap = map + join
Julien Goux
@jgoux
Apr 08 2016 12:00
@Risto-Stevcev It's the alias for my Helpers ^^
Ricardo Pallas
@RPallas92
Apr 08 2016 12:15
This message was deleted
Hi, doy you know if this code could be simpler?
// getSubjectById :: Integer -> Task String [Subject] var getByStudent = compose(chain(compose(R.traverse(Task.of, R.identity), map(rawSubjectToSubject))), getByStudentRaw)
Ricardo Pallas
@RPallas92
Apr 08 2016 12:29
Finally I did
//mergeTaks :: [Task a] -> Task [a]
var mergeTasks = R.traverse(Task.of, R.identity)

//hydrateRawSubjects :: [Raw Subject] -> Task [Subject]
var hydrateRawSubjects = compose(mergeTasks, map(rawSubjectToSubject))

// getSubjectById :: Integer -> Task String [Subject]
var getByStudent = compose(chain(hydrateRawSubjects), getByStudentRaw)
Martin Broder
@mrtnbroder
Apr 08 2016 13:34
Anyone knows how to better compose this with ramda? http://goo.gl/xQAjP8
Julien Goux
@jgoux
Apr 08 2016 14:52
Why setPath or lensPath don't create arrays when you provide an integer ? :o
James Grayling
@jamesgrayling
Apr 08 2016 15:23
How do I concatenate an array of strings intoa single string?
using Ramda
James Forbes
@JAForbes
Apr 08 2016 15:24
R.join()
James Grayling
@jamesgrayling
Apr 08 2016 15:24
thanks
James Forbes
@JAForbes
Apr 08 2016 15:24
:)
David Chambers
@davidchambers
Apr 08 2016 17:48
@jgoux, using function*() {} in this way is clever and does read nicely. It feels a bit magical to me, though.
Drew
@dtipson
Apr 08 2016 18:20
@jgoux is setPath a thing? lensPath doesn't create Arrays, it specifies a focus on a particular location in a complex object
afaik, it handles integers as if they were an Array index: R.view(R.lensPath(['a',1,'b']), {a:[{b:4},{b:5}]});//-> 5
Risto Stevcev
@Risto-Stevcev
Apr 08 2016 19:21
does anyone have experience with sweetjs?
Brad Compton (he/him)
@Bradcomp
Apr 08 2016 19:50
@Risto-Stevcev No, but that looks pretty cool!
Risto Stevcev
@Risto-Stevcev
Apr 08 2016 19:57
@Bradcomp Yeah, definitely. It's backed by Mozilla too. It might be useful for writing fp constructs we've been trying to achieve with other means
Risto Stevcev
@Risto-Stevcev
Apr 08 2016 20:04
@Avaq Nice, yeah that's the direction I was thinking :)
It's still funny to me how almost anything I can think of already exists in JS
Though I think the sweetjs API has changed considerably since then, so I'm not sure those examples will work without needing to update them
Stefano Vozza
@svozza
Apr 08 2016 21:06
If you're going to go to the hassle of using sweetjs, why not just use a language with the features you want?
Raine Virta
@raine
Apr 08 2016 21:10
well you might as well say the same thing about babel
Stefano Vozza
@svozza
Apr 08 2016 21:12
That's why I don't use it, although I only develop on Node so guess it's different for the front end where you don't have a language choice.
Scott Sauyet
@CrossEye
Apr 08 2016 21:19
And what if no languages have the features you want? Macros are incredibly powerful.
Stefano Vozza
@svozza
Apr 08 2016 22:14
So just use Lisp then and be done with it
Walle Cyril
@GrosSacASac
Apr 08 2016 23:50
@Risto-Stevcev upgraded the API a bit like you told me, makes the chat example light