These are chat archives for ramda/ramda

24th
Mar 2016
Jonah
@jonahx
Mar 24 2016 00:44
@prontiol I had tested it like this, which works:
``````var rngN = pipe(of, partial(pipe(useWith(multiply, [identity, Math.random]))))(20)
times(rngN, 10)``````
but apparently only bc times is giving an argument to rngN
Denys Mikhalenko
@prontiol
Mar 24 2016 00:46
docs say:
``fn is passed one argument: The current value of n, which begins at 0 and is gradually incremented to n - 1.``
Jonah
@jonahx
Mar 24 2016 00:46
yeah, that’s what i’m saying, that argument is making it work, whereas it should also work with no arugments, as you pointed out
Denys Mikhalenko
@prontiol
Mar 24 2016 00:48
yeah, that was the main problem actually :-)
Jonah
@jonahx
Mar 24 2016 00:48
going to see if i can fix it while still keeping it shorter, just for fun
Denys Mikhalenko
@prontiol
Mar 24 2016 00:50
here's the curried solution I came up with at first
``R.curryN(2, R.converge(R.multiply, [Math.random, R.identity]))``
Jonah
@jonahx
Mar 24 2016 00:50
does that work?
Denys Mikhalenko
@prontiol
Mar 24 2016 00:50
only if you pass an argument to it
just like yours
so mine was so complicated because I needed to avoid currying
Jonah
@jonahx
Mar 24 2016 00:51
is it impossible to make currying work?
Denys Mikhalenko
@prontiol
Mar 24 2016 00:51
what do you mean?
i provided working example
Jonah
@jonahx
Mar 24 2016 00:52
i thought you just said it avoided currying
Denys Mikhalenko
@prontiol
Mar 24 2016 00:52
ah, yeah
curried functions could not be used here, because they could not be called with `()`
Jonah
@jonahx
Mar 24 2016 00:52
i was just asking if any curruying approach will necessarily be a dead end… ah ok
Denys Mikhalenko
@prontiol
Mar 24 2016 00:53
yeah, as I told before, currying was the root of the problem
so I used `R.wrap` to avoid it
Jonah
@jonahx
Mar 24 2016 02:15
This message was deleted
Jonah
@jonahx
Mar 24 2016 02:24
This message was deleted
Scott Christopher
@scott-christopher
Mar 24 2016 02:25
I don't think ram-bot parses edited messages.
@ram-bot `always(9)()`
ram-bot
@ram-bot
Mar 24 2016 02:25
``9``
Jonah
@jonahx
Mar 24 2016 02:25
ty
Scott Christopher
@scott-christopher
Mar 24 2016 02:25
:)
Jonah
@jonahx
Mar 24 2016 02:26
@prontiol ok my best improvement only shaved a tiny bit off
@ram-bot `pipe(always, of, append(Math.random), useWith(pipe(multiply, Math.floor)), partial(__,[1,1]))(20)()`
ram-bot
@ram-bot
Mar 24 2016 02:26
``8``
James Forbes
@JAForbes
Mar 24 2016 04:42
for any of the Future libraries, is their a built in Futurify function for node style callbacks
Aldwin Vlasblom
@Avaq
Mar 24 2016 08:23
@JAForbes Fluture has `Future.node(done => fs.readFile('package.json', 'utf8', done))` for casting of node-style continuations to Futures. For lifting a function to always return a Future instead of take a Node style continuation, you can use the futurize library.
Tim Navrotskyy
@dypsilon
Mar 24 2016 12:11
@jdalton thank you for input. Well I never liked chaining anyway. Compose/flow/pipe looks much better to me, especially considering that every function in the pipeline may return a promise. The development on lodash/fp seems very promising, sadly I don't have enough resources right now to contribute so I'll have to wait until it's mature enough to use it in the production.
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 13:09
@dypsilon `pipeK` does the same thing as `pipe` except it's doing chaining under the hood. Same with `composeK`
You can also use `do` notation
Denys Mikhalenko
@prontiol
Mar 24 2016 13:11
i don't see @jdalton here though
Tim Navrotskyy
@dypsilon
Mar 24 2016 13:11
@Risto-Stevcev what are the use cases for chaining vs pipe?
Stefano Vozza
@svozza
Mar 24 2016 13:12
you use `chain` when you have functions that return a monadic value
Tim Navrotskyy
@dypsilon
Mar 24 2016 13:13
Aldwin Vlasblom
@Avaq
Mar 24 2016 13:14
@Risto-Stevcev and @dypsilon are talking about different things which both use the word chain.
Stefano Vozza
@svozza
Mar 24 2016 13:14
aha
well i'm going to bow out here because i am not going to start explaining monads when i barely understand them myself
Aldwin Vlasblom
@Avaq
Mar 24 2016 13:16
I believe dypsilon was talking about method chaining: `.foo().bar()` compared to composition: `compose(bar, foo)`. Risto was talking about monadic chaining also known as binding or flatmapping.
James Forbes
@JAForbes
Mar 24 2016 13:16
chaining is immediate, pipe returns a function, chaining only lets you use library functions, pipe let's you use any function.
Tim Navrotskyy
@dypsilon
Mar 24 2016 13:17
so pipe is like chaining but better as in more flexible
James Forbes
@JAForbes
Mar 24 2016 13:17
yes
and pipe allows you to easily reuse your "chains"
Tim Navrotskyy
@dypsilon
Mar 24 2016 13:18
@Avaq is right
@JAForbes yeah, so I was understanding everything correctly
James Forbes
@JAForbes
Mar 24 2016 13:19
oh sorry, I probably was too
@Avaq thanks for the tip with futurize btw :+1:
Tim Navrotskyy
@dypsilon
Mar 24 2016 13:19
Denys Mikhalenko
@prontiol
Mar 24 2016 13:27
so the problem is in lodash size?
Keith Alexander
@kwijibo
Mar 24 2016 13:28
@dypsilon why wouldn't he post that article?
Tim Navrotskyy
@dypsilon
Mar 24 2016 13:29
@kwijibo nothing wrong with the article itself
just the context isn't clear
Keith Alexander
@kwijibo
Mar 24 2016 13:31
seems like the article is like "how to use lodash better", and jdalton wrote lodash and gets thanked in the opening lines?
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 13:50
@dypsilon Oh, you're talking about lodash chaining
Yeah that's not really what `chain` is in functional languages
`compose` is like composition in math. So for example, you have two functions, and you want to feed to return value of one into the other function, like this: `f(g(x))`
In ramda you would write that like this: `R.compose(f, g)(x)`
`pipe` is like `compose` except it reads the other way around, which a lot of people find easier to read because we read left-to-right. So `R.pipe(g, f)(x)` is the same as `R.compose(f, g)(x)`
Tim Navrotskyy
@dypsilon
Mar 24 2016 13:53
@Risto-Stevcev thank you, I understand that
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 13:54
`chain` in functional languages is an operation that can be performed on a type called `Monad`
It's called `bind` in some languages
The easiest way to learn about the different types like `Functor`, `Monoid`, `Semigroup`, `Monad`, etc is to look at the fantasy-land spec
A value that implements the Monad specification must also implement the Applicative and Chain specifications.
Once you've implemented all of the specs that make something a monad, then you can use functions that operate on them, like `pipeK` and `composeK` (aka Kliesli composition)
You can only `chain` together Monads of the same type.
@ram-bot
``S.Just(1).chain(value => S.Just(value + 1))``
Raine Virta
@raine
Mar 24 2016 13:59
@ram-bot `1+1`
ram-bot
@ram-bot
Mar 24 2016 13:59
``2``
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 14:02
In Javascript we have to do it the way that fantasy land does it. In other functional languges it's enforced by the type system itself (usually Hindley-Milner).
There a large toolset of functions that perform generic operations on these types, so that through using the types and partially applying them or composing them, you can start to write a DSL without doing everything from scratch
Tim Navrotskyy
@dypsilon
Mar 24 2016 14:16
@Risto-Stevcev thank you for this lengthy explanation, seems overwhelming at first but it's a great pointer in the right direction for me, I'll study the fantasy-land spec asap, seems very interesting...
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 14:40
Np. Think of these types as something similar to `interfaces` in Java. If a class implements the `Monoid` inferface, for example, it needs to implement the `empty` and `concat` methods. Then you can use your Monoid with any function that operates on Monoids.
The limitations of javascript make it look very much like Java interfaces. However, it should be noted that in fully functional languages, they aren't exactly the same and they're called `typeclasses`. There's no notion of a method or internal state.
Tim Navrotskyy
@dypsilon
Mar 24 2016 14:43
@Risto-Stevcev do you think it's reasonable to use such constructs in JS?
I feel like I'm in the wrong language, lately. Maybe it would be better to move on to clojurescript...
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 14:46
Yeah, you can definitely benefir from them
Julien Goux
@jgoux
Mar 24 2016 14:47
Hi
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 14:47
For example, I wrote a lazy implmentation of the `Either` library that will return a `Left` value if it fails and won't execute the rest of the pipeline
Julien Goux
@jgoux
Mar 24 2016 14:47
It seems that the function "either" of Either isn't exported in ramda-fantasy
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 14:48
Writing that code in plain JS would be really verbose
Julien Goux
@jgoux
Mar 24 2016 14:48
``````{ [Function: Either]
of: [Function],
equals: [Function: equals],
Right: [Function],
Left: [Function] }``````
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 14:48
@jgoux see sanctuary: `S.Either`
Julien Goux
@jgoux
Mar 24 2016 14:48
@Risto-Stevcev ok I'll use it instead
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 14:49
Ramda-fantasy has been superceded by sanctuary, which is currently the go-to for those types.
Julien Goux
@jgoux
Mar 24 2016 14:49
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 14:49
@ram-bot `S.Left(Error('some error'))`
ram-bot
@ram-bot
Mar 24 2016 14:49
``Left(Error: some error)``
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 14:49
Not sure
For example, in JS with ramda you would do invoke a method call to use a Monoid's concat function:
@ram-bot `S.Just([2]).concat(S.Nothing())`
@ram-bot `S.Just([2]).concat(S.Just([3]))`
ram-bot
@ram-bot
Mar 24 2016 14:51
``Just([2, 3])``
Julien Goux
@jgoux
Mar 24 2016 14:52
@Risto-Stevcev thanks it works great with sanctuary :D
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 14:55
In Haskell the type system is built-in:
``````Prelude> (Just [2]) `mappend` (Just [3])
Just [2,3]``````
@dypsilon Clojurescript is nice, but keep in mind that it's also a dynamic language like JS. It does have types but there's no static type checking. There's also ScalaJS, Purescript, and Elm, but I'm reluctant to use these in production code because they're still very new.
Clojurescript is probably the safest for production right now
Lewis
@6ewis
Mar 24 2016 15:04
what do most of you guys use on the backend?
I'm considering throwing goland for clojure
Julien Goux
@jgoux
Mar 24 2016 15:11
I'm using JS
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 15:12
NodeJS here, though I'm very curious about the clojure/clojurescript, scala/scaljs, haskell/purescript stacks and how much more (or less) nice it is than the full js stack. Especially clojure
The limitations of the haskell/purescripts module systems are really off-putting to me. It has severely restricted the growth of the haskell community (cabal hell).
Though I'm wondering if there are similar diamond dependency issues with clojure and scala, haven't looked into it
Denis Stoyanov
@xgrommx
Mar 24 2016 15:16
@Risto-Stevcev instead cabal could be stack
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 15:17
@xgrommx yeah stack is nice
Lately I've been wondering if I've been unfair to Haskell in general, though I have so many painful memories of cabal that I've never had with other languages.
Keith Alexander
@kwijibo
Mar 24 2016 15:18

@Risto-Stevcev Ramda-fantasy has been superceded by sanctuary, which is currently the go-to for those types.

really? I thought they were developed in parallel with some cross-over

Risto Stevcev
@Risto-Stevcev
Mar 24 2016 15:19
I think as an app gets larger and larger, it will run into issues with it's dependencies and/or packaging system. I know I've run into npm fudging up it's module cacheing more than once resulting in non-obvious reasons for my builds breaking.
David Chambers
@davidchambers
Mar 24 2016 15:19
They are parallel projects at this stage. While there's talk of merging the two projects, neither is a subset of the other.
Lewis
@6ewis
Mar 24 2016 15:21
@jgoux nobody use haskell in production though (not that I know of)
LeonineKing1199
@LeonineKing1199
Mar 24 2016 15:21
Node's a good back-end language.
V8 is far from slow. It's threading model is also ideal for web applications
Its
Lewis
@6ewis
Mar 24 2016 15:22
@Risto-Stevcev I played with clojure before, the only reservation I have is that it's not moving nearly fast enough
Scott Sauyet
@CrossEye
Mar 24 2016 15:22
6ewis: Haskell is used on Wall Street a fair bit. Or was a few years ago.
Lewis
@6ewis
Mar 24 2016 15:23
@CrossEye what do you use as main backend lang
Scott Sauyet
@CrossEye
Mar 24 2016 15:24
I don't do back-end much ATM, but new role will mean Node. My current project has a .NET back end, which I'm glad not to have to touch.
LeonineKing1199
@LeonineKing1199
Mar 24 2016 15:25
The only problem with Node is that if something in the even queue throws an unhandled exception, it takes down the whole process.
Julien Goux
@jgoux
Mar 24 2016 15:25
I want to use node.js ecosystem with a static language so Purescript seems really great
LeonineKing1199
@LeonineKing1199
Mar 24 2016 15:26
It's like a slight breeze away from a denial of service
Julien Goux
@jgoux
Mar 24 2016 15:26
Really nice ^^
Keith Alexander
@kwijibo
Mar 24 2016 15:27
yeah that's really nice
Julien Goux
@jgoux
Mar 24 2016 15:28
I don't know if you can incorporate Purescript piece by piece into a JS codebase
Would be awesome that Purescript somehow returns Sanctuary/Ramda-fantasy structures
xD
Keith Alexander
@kwijibo
Mar 24 2016 15:30
I've read that that's (part of) the idea of Purescript; I think the creator started it as a DSL to define some datatypes within a javascript project
I haven't tried it yet however
Lewis
@6ewis
Mar 24 2016 15:31
@jgoux have you considered clojurescript
Julien Goux
@jgoux
Mar 24 2016 15:32
@6ewis not at all, I'm a little afraid of the Lisp syntax
Elixir/Erlang is another trending language on the backend btw
Lewis
@6ewis
Mar 24 2016 15:33
@jgoux How did you learn about FP then?
Dr whatever tutorial?
Elixir/Erlang seems nice but it's not on top of my list
Julien Goux
@jgoux
Mar 24 2016 15:34
And the more I do JS, the more I find I'd need more feature from the language
Like pattern matching
and of course static checking
Keith Alexander
@kwijibo
Mar 24 2016 15:37
yes; it feels like to do FP techniques in Javascript, you have to rely on libraries rather than core language constructs more than would be ideal
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 15:38
@6ewis Yeah, O'Caml and sometimes Haskell are used a lot in the financial sector
Lewis
@6ewis
Mar 24 2016 15:38
@jgoux shit I'm so tempt to read this book
@Risto-Stevcev what would they use it for
Julien Goux
@jgoux
Mar 24 2016 15:38
It's worth the money, I tried to read one or two online books about Haskell before it and they didn't click at all
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 15:39
The thing I really like from O'Caml that isn't in Haskell is that the module system works better (it's ML), and more importantly it has exhaustive pattern matching. So if you pattern match and you forget to add a case, your program won't compile
It's so useful
Julien Goux
@jgoux
Mar 24 2016 15:39
@Risto-Stevcev Doesn't haskell have an extension for this case ?
Lewis
@6ewis
Mar 24 2016 15:40
oddly enough I haven't found a clojure book that teaches all those concepts
Julien Goux
@jgoux
Mar 24 2016 15:40
`{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}` actually it's just a warning ^^
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 15:42
@jgoux Oh neat, didn't know about that one. Thanks for sharing
Though it's still just a warning which sucks
@6ewis It's strong type systems, which is notably stronger than something like Java's type system. A lot of financial calculations need to work properly. Their type systems catch a frightening amount of bugs.
Usually O'Caml is used over Haskell, probably because it's strictly evaluated
It's generally more performant than Haskell
Lewis
@6ewis
Mar 24 2016 15:44
@Risto-Stevcev how come i never hear of O'caml
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 15:44
Not sure
Lewis
@6ewis
Mar 24 2016 15:44
@Risto-Stevcev who use it in production
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 15:44
It's a really nice language
Jane Street is probably the more famous one using it
Lewis
@6ewis
Mar 24 2016 15:44
Jane street?
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 15:45
Lewis
@6ewis
Mar 24 2016 15:45
@Risto-Stevcev do you know a ocaml book that would teach all those concepts
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 15:45
O'Caml is also used a lot as a compiler for programming languages, probably again because of the exhaustive pattern matching and strict evaluation
Like Haskell, it's also grown considerably in popularity over the past couple of years
People are increasingly becoming disillusioned by OO programming and embracing the functional paradigm in general
Until fairly recently, for example, Haskell didn't have Stackage, and O'Caml didn't have a package manager and ecosystem
Pattern matching exhaustively over an AST is easy in O'Caml
Lewis
@6ewis
Mar 24 2016 15:48
@Risto-Stevcev do you know ocaml?
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 15:49
I learned it in school for a programming languages course
I'm not 100%, I would still like to get to the point of publishing something on OPAM and learning some more advanced things. But I can get around.
Rust also looks really nice for systems programming as an alternative to C
I'd definitely like to try that one out
Lewis
@6ewis
Mar 24 2016 15:52
there are too many languages out there. it's like girls to me - I can't make up my mind
LeonineKing1199
@LeonineKing1199
Mar 24 2016 15:52
Julien Goux
@jgoux
Mar 24 2016 15:58
Ocaml is used for Flow if I'm not wrong
here ^^
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 16:01
@6ewis I agree. And there are libraries and which one should I choose? There are like 10 different libraries for a nodejs http server, 5 different FRP libraries, etc...
Takes more time to learn about each language/library than to develop in them
It reminds me of the Barry Schwartz book The Paradox of Choice
Julien Goux
@jgoux
Mar 24 2016 16:03
As long as I learn something new when I switch I'm ok with all these choices
Try, take the best part, repeat
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 16:04
@jgoux I don't like it when I want to make the best possible app, because you can't really know all of the ins and outs of a particular language and library until you've really dug into it. And if you don't like it, or it's not the best for your domain, then you're pretty much stuck with it for a while
But as something to keep my mind occupied and to make toy programs, it's fun and refreshing to have all those choices
Lewis
@6ewis
Mar 24 2016 16:14
@Risto-Stevcev I haven't read that book
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 16:17
@jgoux Flow looks interesting, though the Facebook `PATENTS` clause has been worrying me and makes me reluctant to adopt some of it's tech like React
Lewis
@6ewis
Mar 24 2016 16:20
@Risto-Stevcev I've also considered F#
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 16:22
Yeah I've heard good things about F#, but never tried it
Denis Stoyanov
@xgrommx
Mar 24 2016 16:49
@Risto-Stevcev f# is awesome
Lewis
@6ewis
Mar 24 2016 16:59
@xgrommx are you a f# guy?
Denis Stoyanov
@xgrommx
Mar 24 2016 17:03
@6ewis no, I just try it also as haskell
but now I use javascript on my work
Jonah
@jonahx
Mar 24 2016 17:08
anyone working with node on the backend? what libraries are you using to work with you postgresql dbs and are you happy with them?
Stefano Vozza
@svozza
Mar 24 2016 17:14
Pusher use haskell on the backend.
Lewis
@6ewis
Mar 24 2016 17:16
@svozza pusher?
Stefano Vozza
@svozza
Mar 24 2016 17:17
Web sockets as a service. Github use them for dynamic updates.
John-David Dalton
@jdalton
Mar 24 2016 17:22
@dypsilon @kwijibo @prontiol It's not an article. That's how Medium displays a single blog post comment. You'll see at the top it links back to the parent blog post the rely is to.
boxofrox
@boxofrox
Mar 24 2016 20:17
I'm confused why `all` and `none` always return `true` when given an empty list.
``````[ R.all(R.isNil, []),
R.all(R.complement(R.isNil), []),

R.none(R.isNil, []),
R.none(R.complement(R.isNil), []),
]
//=> [true, true, true, true]``````
I kind of expect some inversion there like `[false, true, true, false]`. Particularly in the first case, nothing passed the predicate because nothing was tested.
Jonah
@jonahx
Mar 24 2016 20:22
@boxofrox i think it’s because if there is nothing test, the default is true, which is the behavior i think you’d want in most applications
sort of how the statement “If I am dead, I am king” is true, because i’m not dead
In the first example, maybe you want to show an error if all of the user’s entries are blank (nil), because it’s required that he fills in at least one. But if the degenerate case where there are no entries to fill in, it makes sense not to show an error. Actually, that would argue for it being false…. so, well, I don’t know :)
boxofrox
@boxofrox
Mar 24 2016 20:28
Yea, that's the exact situation I'm in.
Anywho. It's not apparent in the docs that an empty list will return `true`. If that had been in there, I wouldn't have tried to rely solely on `all` and `none` to validate whether all fields are empty or full.
Jonah
@jonahx
Mar 24 2016 20:30
Anyway, I think the idea is that something it’s true unless a counterexample is found, so empty is by necessity true since there are no possible counterexamples. but i suppose that’s not always what you want
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 20:31
@boxofrox It's a limitation of how ramda is expressing partial functions
`R.all` and `R.none` are partial functions in that the behavior is not well defined for an empty list
Same with R.head: `R.head([]); //=> undefined`
It should really be returning `S.Nothing`, `S.Just(true)` or `S.Just(false)`
and R.head should really be returning `S.Nothing()` instead of `undefined`, and `S.Just(element)` if there's an element
It was probably set to return `true`in the expectation that it would lead to the least surprise to the developer. But I don't think that's the case
boxofrox
@boxofrox
Mar 24 2016 20:35
@Risto-Stevcev that I can understand. I think least surprise might change from situation to situation. @jonahx and I just happen to find one use-case where we were surprised.
I'll submit a PR to update the docs for `all` or `none` to explicity declare `true` is returned against empty lists.
Thanks for the explanations @jonahx and @Risto-Stevcev .
Jonah
@jonahx
Mar 24 2016 20:36
@Risto-Stevcev Just noticed you are Columbia alum, so am I.
joneshf-work1
@joneshf-work1
Mar 24 2016 20:38
I noticed that `R.lift` has to be manually curried. What forces this requirement?
LeonineKing1199
@LeonineKing1199
Mar 24 2016 21:11
This message was deleted

Almighty Ramda gurus, I have a problem I'm trying to solve.

We have two aligned arrays. One is an array of objects and one is an array of values.

Basically,

``````let a = [{ text: 'string' }];
let b = ['new string'];``````

Now, what I want is a new array of objects with each one evolved with the value of the corresponding index of b.

So basically the result of the operation would be:
``[{text: 'new string'}]``
I have literally never been more tempted to write a for-loop. Someone... Stop me!
Jonah
@jonahx
Mar 24 2016 21:15
@LeonineKing1199 don’t do it! gimme a sec
LeonineKing1199
@LeonineKing1199
Mar 24 2016 21:15
I could turn my two arrays into one array of pairs...
Jonah
@jonahx
Mar 24 2016 21:17
``zipWith(assoc('text'), b, a)``
LeonineKing1199
@LeonineKing1199
Mar 24 2016 21:18
Phew. That was close. Thank you so much!
I was looking through the docs and had literally just gotten to zip and lo and behold, you recommend zipWith just in time XD
Jonah
@jonahx
Mar 24 2016 21:18
Merely doing my civic duty
LeonineKing1199
@LeonineKing1199
Mar 24 2016 21:18
Thanks!
Remember, only you can prevent for-loops :P
Jonah
@jonahx
Mar 24 2016 21:19
exactly! <3
Risto Stevcev
@Risto-Stevcev
Mar 24 2016 21:20
@jonahx Nice, what year were you?
Jonah
@jonahx
Mar 24 2016 21:21
@Risto-Stevcev let’s just say the numbers at the end of my email id are “27"
97’
LeonineKing1199
@LeonineKing1199
Mar 24 2016 21:42
Realk talk, that zipWith and assoc were good choices.
I knew there had to be a Ramda-y way of doing what I wanted.
Scott Sauyet
@CrossEye
Mar 24 2016 22:23
@boxofrox, @jonahx, @Risto-Stevcev: The behavior of `all` on empty lists is quite intentional, and well founded: https://en.wikipedia.org/wiki/Vacuous_truth.
Jonah
@jonahx
Mar 24 2016 22:24
@CrossEye that’s what i guessed in my previous posts. but in some cases (see the example from previous discussion) it’s not what you want. not saying the design is wrong or even suboptimal, just that cases exist where you want vacuous… falsehood.
Scott Sauyet
@CrossEye
Mar 24 2016 22:25
Perhaps, but a generic function really needs to deal with it this way.
Jonah
@jonahx
Mar 24 2016 22:25
yeah, i’m sure it was the best choice
@CrossEye btw, not sure if you saw my question from this morning, or even if you do node backend work, but if so what library do you like for interacting with postgres? ditto for building apis?
Scott Sauyet
@CrossEye
Mar 24 2016 22:28
I am just switching to a position where I will do more Node, but I have never connected to postgres from it. I'm not sure what you mean for a library for building APIs. In what sense?
boxofrox
@boxofrox
Mar 24 2016 22:29
@CrossEye, thanks for the clarification.
Jonah
@jonahx
Mar 24 2016 22:30
meaning, express, or koa, (not specifically for APIs necessarily), or something that touts auto REST building like loopback. or other? as you might guess from my interest in ramda, my tastes lie toward simplicity and lack of magic, but i also don’t like to reinvent the wheel
joneshf-work1
@joneshf-work1
Mar 24 2016 22:33
@jonahx If I may chime in, `pg-promise` is worlds easier to deal with than `pg`.
Mostly because of the promises
but also because it removes a bit of cruft from `pg`.
Jonah
@jonahx
Mar 24 2016 22:36
@joneshf-work1 please do chime in. thanks for the rec.
do you have on thoughts on API frameworks / libraries?
Scott Sauyet
@CrossEye
Mar 24 2016 22:37
I've mostly used Node lately for tools, and not for web apps or for service layers. That's about to change, and I guess I will have to start considering these things.
Jonah
@jonahx
Mar 24 2016 22:38
@CrossEye i’d appreciate you passing along any thoughts as you do your research, as i’m in the same boat atm
joneshf-work1
@joneshf-work1
Mar 24 2016 22:38
In node? nope
Scott Sauyet
@CrossEye
Mar 24 2016 22:39
OK. I've never had great luck with any auto-REST tools, though, when I did use them. I've rolled my own several times, and they were quite easy to write. There's supposed to be an awesome one in, I can't remember, either Haskell or Clojure. But I haven't played with it.
joneshf-work1
@joneshf-work1
Mar 24 2016 22:40
servant?
Scott Sauyet
@CrossEye
Mar 24 2016 22:40
Maybe, but that doesn't ring a bell.
Jonah
@jonahx
Mar 24 2016 22:40
Yeah, I’m thinking about just rolling my own in koa…
joneshf-work1
@joneshf-work1
Mar 24 2016 22:41
what's the selling point of koa?
I hear talk, but never delved into it
Mar 24 2016 22:41
Servant is super cool
joneshf-work1
@joneshf-work1
Mar 24 2016 22:41
!
Scott Sauyet
@CrossEye
Mar 24 2016 22:41
It was a DB -> REST infrastructure, that's all I recall, in a language that I can read but not write. (Like far too many of them.)
Jonah
@jonahx
Mar 24 2016 22:42
@joneshf-work1 it’s basically like sinatra for node. which express is too, but koa is the next generation of express (built by same people), and essentially, everything is middeware. so if you are library-oriented rather than framework-oriented, it should appeal to you
joneshf-work1
@joneshf-work1
Mar 24 2016 22:44
interesting
Keith Alexander
@kwijibo
Mar 24 2016 23:02
Koa is generator based isn't it?
Jonah
@jonahx
Mar 24 2016 23:02
yeah
the middlewares use `yield` to chain
Juan Soto
@sotojuan
Mar 24 2016 23:07
Is there a function to aggreate values from a list? Example: `[a, a, b, b, b]` => `{a: 2, b: 3}`
`countBy`, phew.