These are chat archives for ramda/ramda

23rd
Feb 2016
Richard Seldon
@arcseldon
Feb 23 2016 00:01 UTC
lol, ok.
David Chambers
@davidchambers
Feb 23 2016 01:07 UTC
Can anyone recommend a JavaScript HTML parser? Preferably one with a function-based rather than method-based API.
The options are daunting.
Scott Christopher
@scott-christopher
Feb 23 2016 01:11 UTC
I know Bodil has written a parser combinator library in JS, so depending what you want to extract from the HTML that might be an option.
Scott Sauyet
@CrossEye
Feb 23 2016 01:12 UTC
what's the goal with this?
Do you want to be able to parse the tag soup of the open web or some restricted subset?
I understand wanting a principled
API
But there is a big difference between parsing anything and everything that claims to be HTML and things which validate against some spec .
Scott Christopher
@scott-christopher
Feb 23 2016 01:15 UTC
David Chambers
@davidchambers
Feb 23 2016 01:16 UTC
Thanks for the link, @scott-christopher.
Scott Sauyet
@CrossEye
Feb 23 2016 01:18 UTC
I played around with eulalie a bit, and it's convenient and powerful, but I still have a hard time imagining using it for tag soup.
David Chambers
@davidchambers
Feb 23 2016 01:18 UTC
To answer your question, @CrossEye, we're looking for a replacement for cheerio. The problem with cheerio is it forces us to break out of our beautiful Ramda pipelines. Its map method takes (idx, el) and sets this. It has its own methods for slicing and doing various things we could easily do if only we had an array rather than a fancy cheerio object.
Scott Sauyet
@CrossEye
Feb 23 2016 01:18 UTC
ah, yes, run into that a few times.
David Chambers
@davidchambers
Feb 23 2016 01:19 UTC
We'll likely end up using htmlparser2, as cheerio does, since we know it handles anything that even remotely resembles valid HTML.
James Forbes
@JAForbes
Feb 23 2016 02:54 UTC

re: removing R.call, I use it a lot when dealing with wrapped values in mithril/flyd.

If you did choose to remove its not a big issue, but just wanted to let you guys know that I have a use for it. Maybe others do too?

David Chambers
@davidchambers
Feb 23 2016 02:56 UTC
Could you switch to using R.apply?
Scott Sauyet
@CrossEye
Feb 23 2016 02:59 UTC
That would clearly involve wide-ranging, but hopefully simple, code change.
@JAForbes: we wouldn't do it without a more significant discussion, and without room for feedback.
James Forbes
@JAForbes
Feb 23 2016 04:04 UTC
@davidchambers R.apply will stay curried unless it receives an array of arguments. But these wrapped values should never receive an argument. I could use R.nAry(0, ... ), but it is less clear what is going on than R.call.
@CrossEye that's good to know, I don't mind if its removed just wanted to mention it, I see it is a pretty useful primative
Hardy Jones
@joneshf
Feb 23 2016 04:25 UTC
@davidchambers maybe you could "Adapt" cheerio to be more principled.
Hardy Jones
@joneshf
Feb 23 2016 04:34 UTC
function PrincipledCheerio($) {
  return function() {
    return Object.create($.apply($, arguments), {
      map: f => $.map((_, x) => f(x)),
    }
  });
}
Somethig like that?
I dunno if that actually works or not.
Just going by the api docs they have inthe readme.
David Chambers
@davidchambers
Feb 23 2016 06:56 UTC
@JAForbes, I didn't realize you're dealing with thunks. I can see the value of R.call in that case.
@joneshf, we could certainly do that. Cheerio itself, though, is really just a veneer for htmlparser2 and css-select. I think untangling the silliness might be more work than building something on top of htmlparser2 and css-select directly.
James Forbes
@JAForbes
Feb 23 2016 07:36 UTC
@davidchambers R.nAry(0, thunk) is a lot safer in any case, as R.call may accidentally set/push a value. So maybe I should just bite the bullet and move away from R.call anyway.
Jakub Korzeniowski
@kujon
Feb 23 2016 11:00 UTC

I'm working on some generalised sorting utilities and i've got the following type signatures:

// Direction :: 1 | -1
// SortLens :: Ord a => Lens s a
// sortBy :: SortLens -> Direction -> [s] -> [s]

do you think there should be a type alias for s in sortBy signature (something like Comparable s) or is s itself enough?

Scott Sauyet
@CrossEye
Feb 23 2016 12:31 UTC
@kujon: I don't see the need for it. But notice that this, while adding the flexibility of Direction, loses some of what ˋR.sortByˋ offers. For instance:
R.sortBy(person => person.lastName +
R.sortBy(person => person.last + ' ' + person.first)
(sorry)
That's not the sort of thing you'd do with a Lens.
Jakub Korzeniowski
@kujon
Feb 23 2016 12:47 UTC
yeah, good point. and I presume writing a lens for such a derived value only for sorting purposes doesn't make sense. thanks!
Hardy Jones
@joneshf
Feb 23 2016 15:50 UTC
:point_up: February 20, 2016 2:07 PM Late to the party, but I was just reminded of another way:
@ram-bot
R.sequence(R.always, [R.add(10), R.multiply(2), R.dec])(5)
ram-bot
@ram-bot
Feb 23 2016 15:50 UTC
[ 15, 10, 4 ]
Hardy Jones
@joneshf
Feb 23 2016 15:54 UTC
Piggy backing off of this you can do something like:
const juxt = R.traverse(R.always, R.apply);
modulo applying currying
oh wait, juxt doesn't take an array as the second argument
maybe more in depth.
Scott Sauyet
@CrossEye
Feb 23 2016 16:14 UTC
ram-bot ˋR.converge(Array.of([R.add(10), R.multiply(2), R.dec])(5)ˋ
Ludwig Magnusson
@TheLudd
Feb 23 2016 16:15 UTC
Would it be possible to rename the bot to just ram-bo? :D
Scott Sauyet
@CrossEye
Feb 23 2016 16:16 UTC
@ram-bot ˋR.converge(Array.of([R.add(10), R.multiply(2), R.dec])(5)ˋ
hmmm
Hardy Jones
@joneshf
Feb 23 2016 16:16 UTC
@CrossEye @
Scott Sauyet
@CrossEye
Feb 23 2016 16:16 UTC
d'oh
Hardy Jones
@joneshf
Feb 23 2016 16:16 UTC
also, your backticks dont seem to be working
Aldwin Vlasblom
@Avaq
Feb 23 2016 16:17 UTC
> "ˋ" === "`"
false
Somehow.
Scott Sauyet
@CrossEye
Feb 23 2016 16:17 UTC
@ram-bot ˋR.converge(Array.of([R.add(10), R.multiply(2), R.dec])(5)ˋ
Hardy Jones
@joneshf
Feb 23 2016 16:18 UTC
@ram-bot "ˋ".charCodeAt(0)
ram-bot
@ram-bot
Feb 23 2016 16:18 UTC
715
Scott Sauyet
@CrossEye
Feb 23 2016 16:18 UTC
don't know what's up with this new ˋkeyboardˋ. :frowning:
Hardy Jones
@joneshf
Feb 23 2016 16:18 UTC
@ram-bot "".charCodeAt(0)`
ram-bot
@ram-bot
Feb 23 2016 16:18 UTC
SyntaxError: Unexpected token ILLEGAL
Hardy Jones
@joneshf
Feb 23 2016 16:19 UTC
ah
Aldwin Vlasblom
@Avaq
Feb 23 2016 16:19 UTC
@joneshf Haha, that was to be expected. ^^
Hardy Jones
@joneshf
Feb 23 2016 16:19 UTC
:)
@ram-bot
"`".charCodeAt(0)
ram-bot
@ram-bot
Feb 23 2016 16:19 UTC
96
Hardy Jones
@joneshf
Feb 23 2016 16:19 UTC
there
Scott Sauyet
@CrossEye
Feb 23 2016 16:20 UTC
this one work?
ok
bummer. New tablet with a really nice keyboardd. Misdoes the backtick. Have to figure that out.
Hardy Jones
@joneshf
Feb 23 2016 16:20 UTC
what tablet?
and what keyboard?
Scott Sauyet
@CrossEye
Feb 23 2016 16:21 UTC
In any case, that's how juxt is defined now.
Nexus 9, separate physical keyboard.
Fingers actually fit.
Hardy Jones
@joneshf
Feb 23 2016 16:21 UTC
is it like a nexus specific keyboard?
Scott Sauyet
@CrossEye
Feb 23 2016 16:23 UTC
built to be a companion, I believe, but sold separately.
Just a folio cover with a keyboard.
so much nicer for me than on-screen. Many fewer typos.
And I swear the backtick has worked. I don't know if I did something...
ˋtestˋ
hmmm
now?
aha!
@ram-bot R.converge(Array.of([R.add(10), R.multiply(2), R.dec]))(5)
ram-bot
@ram-bot
Feb 23 2016 16:27 UTC
SyntaxError: missing ) after argument list
Scott Sauyet
@CrossEye
Feb 23 2016 16:28 UTC
@ram-bot R.converge(Array.of([R.add(10), R.multiply(2), R.dec]))(5)
I give up. Got the backtick working. I think that earns me lunch. :smile:
Hardy Jones
@joneshf
Feb 23 2016 16:33 UTC
haha
Risto Stevcev
@Risto-Stevcev
Feb 23 2016 16:33 UTC
@ram-bot R.traverse(Maybe.of, R.negate, [Just(1), Just(2), Just(3)])
Hardy Jones
@joneshf
Feb 23 2016 16:34 UTC
@Risto-Stevcev it has to be a new message prefixed with the @ram-bot, it doesn't respond to edits.
Risto Stevcev
@Risto-Stevcev
Feb 23 2016 16:34 UTC
@ram-bot R.traverse(Maybe.of, R.negate, [Just(1), Just(2), Just(3)])
ram-bot
@ram-bot
Feb 23 2016 16:34 UTC
ReferenceError: Just is not defined
Risto Stevcev
@Risto-Stevcev
Feb 23 2016 16:34 UTC
@ram-bot R.traverse(S.Maybe.of, R.negate, [S.Just(1), S.Just(2), S.Just(3)])
Hardy Jones
@joneshf
Feb 23 2016 16:34 UTC
S.Just
and then S.Maybe.of
Risto Stevcev
@Risto-Stevcev
Feb 23 2016 16:35 UTC
@ram-bot R.traverse(S.Maybe.of, R.negate, [S.Just(1), S.Just(2), S.Just(3)])
ram-bot
@ram-bot
Feb 23 2016 16:35 UTC
TypeError: ‘Maybe#map’ expected a value of type Function as its first argument; received undefined
Hardy Jones
@joneshf
Feb 23 2016 16:35 UTC
wat
Risto Stevcev
@Risto-Stevcev
Feb 23 2016 16:36 UTC
example in the docs isnt working
Hardy Jones
@joneshf
Feb 23 2016 16:36 UTC
oh
Risto Stevcev
@Risto-Stevcev
Feb 23 2016 16:36 UTC
tried it on tonic too
Hardy Jones
@joneshf
Feb 23 2016 16:36 UTC
yeah, that shouldn't work.
Risto Stevcev
@Risto-Stevcev
Feb 23 2016 16:37 UTC
docs say it should be //=> Just([-1, -2, -3])
Hardy Jones
@joneshf
Feb 23 2016 16:37 UTC
@ram-bot R.traverse(S.Maybe.of, R.compose(S.Just, R.negate), [1,2,3])
ram-bot
@ram-bot
Feb 23 2016 16:37 UTC
Just([-1, -2, -3])
Hardy Jones
@joneshf
Feb 23 2016 16:37 UTC
the docs are wrong.