These are chat archives for ramda/ramda

30th
Apr 2017
kerembaydogan
@kerembaydogan
Apr 30 2017 00:27 UTC
hi guys
is ramda amd compatible?
if so i am having trouble with requirejs integration
Galileo Sanchez
@galileopy
Apr 30 2017 05:43 UTC
I use browserify and it works well. I'm not familiar with amd though
kerembaydogan
@kerembaydogan
Apr 30 2017 11:41 UTC
thanks man, I solved it. If you don't use imported dependency ( in this case it is 'R' ) requirejs or chrome v8 marks it as undefined. After I did some operations with R. It is loaded.
Michael Rosata
@mrosata
Apr 30 2017 16:01 UTC
If I were explaining the meaning of the typeclass "Filterable" in the type sig filter :: Filterable f => (a -> Boolean) -> f a -> f a, would it be appropriate to say that "Filterable is an abstract data structure in that it doesn't exist as something which can be instantiated, assigned to or compared with. Rather, it states that the type f should conform to an imaginary "Filterable" specification. This specification would essentially be anything that can be filtered, a plain old JavaScript Object, an object with a filter method or an Array."
Rick Medina
@rickmed
Apr 30 2017 16:40 UTC
@mrosata I'd base it on the focus of the explanation, eg, target audience and target concept (is the topic the type system, the operations...?)
Rick Medina
@rickmed
Apr 30 2017 16:46 UTC
I assume is the former so I would say that Filterable is not a class in terms of OOP as in a blueprint to create stuff but a set of properties that structures have in common, so more like a spec or a constraint, like the class C of Mercedes Benz
Rick Medina
@rickmed
Apr 30 2017 17:01 UTC
and then go to explain how the operation is implemented for each specific data structure. So is more about the semantics of an operation and be able to reason about it for different structures equivalently
did I help at all? :sweat_smile:
Michael Rosata
@mrosata
Apr 30 2017 17:09 UTC
@rickmed Yes it did. I didn't think to go into how the op worked over the different structures. The topic is the type system, targeted at someone who just learned about basic type sigs, they know arbitrary types of input and output can be annotated IE: a -> b, or more specific types [a] -> Number, and then I wanted to just broadening that understanding a little more to show that we can include more generalized types, not any arbitrary a or b, but also not something so specific as an Array. Parametric polymorphism without using scary words like "parametric" or "polymorphism". Also without introducing Fantasy land. That's why I thought Filterable would be a great example because it wouldn't lead to down the 'this must implement that which must implement that' rabbit hole
I like the class C example
Michael Rosata
@mrosata
Apr 30 2017 17:16 UTC
Maybe even stringUp :: (StringInstrument g) => [String] -> g, StringedInstrument could be some form of a guitar or it could be something like Ukulele, so the signature couldn't' use [String] -> Guitar, but it also couldn't use [String] -> a
Rick Medina
@rickmed
Apr 30 2017 17:16 UTC
ok so I think that would enough for now then -you could later extend the car analogy. One thing is I wouldn't hide the "scary" words. Just explain them in simple concepts like those and the meaning of words (poly = many, parametric = parameters, morphism = shape/form), etc...

I like the class C example

It makes fp look fancy as well :wink:

Michael Rosata
@mrosata
Apr 30 2017 17:17 UTC
fp is fancy
@rickmed Thanks for the advice
Rick Medina
@rickmed
Apr 30 2017 17:19 UTC
@mrosata my pleasure
Shawn Talbert
@ShawnTalbert
Apr 30 2017 17:20 UTC
Anyone know of a library (perhaps Ramda) that defines a sequence/iteration protocol so I can define custom sequences, similar to (LazyJS)[http://danieltao.com/lazy.js/]?
Rick Medina
@rickmed
Apr 30 2017 17:22 UTC
@mrosata note that type "class" in ML is almost literally the same meaning as in english vs in OOP.
Shawn Talbert
@ShawnTalbert
Apr 30 2017 17:26 UTC
Specifically, I'm wondering if Ramda can let me define my own sequence similar to LazyJS http://danieltao.com/lazy.js/docs/#Sequence-define
Michael Rosata
@mrosata
Apr 30 2017 17:35 UTC
@rickmed :thumbsup:
Rick Medina
@rickmed
Apr 30 2017 17:38 UTC
@ShawnTalbert the closest thing is that some functions support transducers behaviour
Denis Stoyanov
@xgrommx
Apr 30 2017 17:42 UTC
Most.js rescue you
Shawn Talbert
@ShawnTalbert
Apr 30 2017 17:46 UTC
Thanks @xgrommx , will take a look at that one. And thx rick - I have't worked with tranducers but at first glance they don't seem to be about defining source data for a stream?
Rick Medina
@rickmed
Apr 30 2017 18:01 UTC
@ShawnTalbert The main difference is that transducers collapse to a final structure and with streams you can do side effects with each value once at a time
Shawn Talbert
@ShawnTalbert
Apr 30 2017 18:02 UTC
How do I define the steam itself?
LazyJS allows me to just implement an interface then I can use the result as an iterable sequence with all the LazyJS methods just like I can an native JS array.
Rick Medina
@rickmed
Apr 30 2017 18:07 UTC
you pass it something and it converts it to a producer of values once at a time: an array, a dom event, a generator function..
then you have operators that transform/filter/etc values as they are pushed into the sequence once a a time and finally you have an operator to do side effects with the value transformed through the operators chain
Shawn Talbert
@ShawnTalbert
Apr 30 2017 18:10 UTC
that last one might work - In my case I'm essentially surfacing an arbitrarily large data set from a database as a sequence
the transformations on stream values isn't my challenge, it's getting my database results to be treated as a 'stream'. Maybe the generator function is something I can work with, though I need to run in an ES5 environment
OO languages typically have a simple generic notion of Iterable or similar, allowing you to completely define how a 'sequence' of values is created. If a ES6 generator is as close as I can get with Ramda I might be stuck.
Rick Medina
@rickmed
Apr 30 2017 18:12 UTC
how are you connecting to the db?
IIUC your case, ramda won't help as its own (maybe as util functions within the chain to whatever abstraction you choose to use)
Shawn Talbert
@ShawnTalbert
Apr 30 2017 18:16 UTC
right, that was the 'killer feature' for me of LazyJS - it treats a sequence as a protocol, of which Arrays or DOM events are just a couple implementations. However development seems stalled on LazyJS and the TypeScript declarations are too old. It looks like Most.js as @xgrommx mentioned may be a reasonable fit, if I can find documentation of how to create my own custom Stream or Source or whatnot
I do like ramda's overall api though
Denis Stoyanov
@xgrommx
Apr 30 2017 18:17 UTC
Also Rx or flyd
Rick Medina
@rickmed
Apr 30 2017 18:21 UTC
@ShawnTalbert I would recommend rxjs, it is a bit heavy but it doesn't matter since it is on the back end and probably has the best documentation, stack overflow wuestions, active gitter etc and has an api that you can create a stream like onNext(pass value), onError, onComplete, and transform them through the chain
you can use ramda as the "inner transformation" functions
Shawn Talbert
@ShawnTalbert
Apr 30 2017 18:37 UTC
thanks Rick. I am hopeful to find a single library that I can apply both client side and server side. Till now I've used a combination of Lodash and LazyJS, but liked the FP orientation of Ramda. I see even lodash has a 'fp' flavor but I don't see anything about creating custom sequences there either.
Rick Medina
@rickmed
Apr 30 2017 18:44 UTC
rxjs works perfectly in both environments, the "heaviness" is subjective vs other libs. But if you're using something like angular it won't make a difference
Shawn Talbert
@ShawnTalbert
Apr 30 2017 18:45 UTC
Client-side I'm more of an Aurelia person than Angular but I see rxjs has some buzz in the Angular world
you can just implement Iterable or Observable
Shawn Talbert
@ShawnTalbert
Apr 30 2017 18:53 UTC
Nice @gabejohnson . Can one implement Iterable in ES5?
Shawn Talbert
@ShawnTalbert
Apr 30 2017 19:00 UTC
I'll dig in a bit more. I seem to recall trying some library that supported the iterator protocol but ran into some sort of block. Thanks all, I realize this turns out to be a bit off topic for Ramda!
Rick Medina
@rickmed
Apr 30 2017 19:19 UTC
Iterables ("IEnumerables") and Iterators ("IEnumerators") are exactly the dual of Observables (rxjs streams) and Observers as a realization of the continuation Monad. JS (et al) Generators objects (not functions) are both iterators and iterables so they are exactly the dual of rxjs Subjects.
the former are pull based and the latter push based
Shawn Talbert
@ShawnTalbert
Apr 30 2017 19:22 UTC
10-4