These are chat archives for ramda/ramda

22nd
Sep 2015
Chet Harrison
@ChetHarrison
Sep 22 2015 03:27
Damn eie.io is taken
David Chase
@davidchase
Sep 22 2015 04:28
just for anyone interested i updated http://davidchase.github.io/ramtuary/, now uses babel and latest code mirror, also captures console.log, examples are done via code that gets compiled to json which in turn gets browserfied.. added tab support… let me know what you guys think :D
hemanth.hm
@hemanth
Sep 22 2015 04:48
@davidchase Awesome! :clap: :sparkles:
hemanth.hm
@hemanth
Sep 22 2015 04:55
it would be nice if we could avid the horizontal scroll
Raine Virta
@raine
Sep 22 2015 06:17

@davidchambers in node 4.1, I get

> Just(1)
Just { value: 1 }

0.12 gives me { value: 1} though

so I'm not sure if I should do anything about that
David Chambers
@davidchambers
Sep 22 2015 06:37
I like the idea of REPL output being valid input. ;)
Raine Virta
@raine
Sep 22 2015 06:43
I can see it being useful, occasionally
David Chambers
@davidchambers
Sep 22 2015 06:44
I think the isomorphism is nice. I enter 'foo', I get back 'foo'. I enter [1, 2, 3], I get back [1, 2, 3]. When I enter Just(1), I expect to get back Just(1) rather than some other representation of that value.
Raine Virta
@raine
Sep 22 2015 06:50
util.inspect is great because it looks nice and formats deep structures nicely
perhaps a command:
> S.Just(1)
Just { value: 1 }
> .str
Just(1)
David Chambers
@davidchambers
Sep 22 2015 06:52
Yes. It depends whether one wishes to optimize for deeply nested structures or simpler values. These are the sorts of design decisions that make me excited about the recent explosion of interest in Ramda/Node REPLs. It's good to have options.
I didn't know about .str. That's neat!
Raine Virta
@raine
Sep 22 2015 06:53
it doesn't exist
(yet) ;)
David Chambers
@davidchambers
Sep 22 2015 06:53
I like it! I hope it exists one day. ;)
Martin Algesten
@algesten
Sep 22 2015 08:15
notice
that you can override .inspect() to take control over that output too
so even a deep structure could show as proper output.
David Chambers
@davidchambers
Sep 22 2015 08:20
I got angry last time I used util.inspect because I read that it supports {depth: null} as another way to specify infinite depth, when the language provides the perfect value: Infinity. As a rule, reading documentation for JavaScript libraries either makes me :angry: or :disappointed:.
Raine Virta
@raine
Sep 22 2015 08:21
Infinity can be overwritten, I don't know if that would have to do with it though
David Chambers
@davidchambers
Sep 22 2015 08:23
Why have a consistent type when one could instead introduce a magic value of another type? >.<
Martin Algesten
@algesten
Sep 22 2015 09:10
@raine apart from not telling me off, i can’t overwrite it, can I?
> Infinity = 42
42
> Infinity
Infinity
Raine Virta
@raine
Sep 22 2015 09:14
my mistake, you can't overwrite it like that. but you can shadow it with a function argument
Martin Algesten
@algesten
Sep 22 2015 09:26
@raine do you want bug reports on replem?
in your issue tracker i mean.
Raine Virta
@raine
Sep 22 2015 09:27
yes please
Tobias Pflug
@gilligan
Sep 22 2015 10:36
Can someone suggest an alternative/improvement something like const foo = R.has('x', foo) ? R.over(xLens, f, foo) : foo ? so i basically want to map f over a maybe functor (i guess) but of course my lens (which just happens to be a R.lensProp) will just return undefined and thus f will crash.
R.ifElse(R.has('x'), R.over(xLens, f), R.identity);
would at least be more concise. guess that is as good as it gets ?
Raine Virta
@raine
Sep 22 2015 10:38
R.evolve?
R.evolve({ x: f })
Tobias Pflug
@gilligan
Sep 22 2015 10:39
@raine ah, yes - that would probably make sense
@raine thank you
i need to be pointed at functions at times for specific problems until i have them in my mental repertoire
hemanth.hm
@hemanth
Sep 22 2015 10:42
@raine Normally one use fmap over a MayBe to get the value right?
Raine Virta
@raine
Sep 22 2015 10:43
@hemanth what do you mean by getting the value?
hemanth.hm
@hemanth
Sep 22 2015 10:43
Like 1 from Just { value: 1 }
Raine Virta
@raine
Sep 22 2015 10:44
no fmap is for mapping the value inside with a pure function, without leaving the container
Raine Virta
@raine
Sep 22 2015 10:52
not sure if that was quite right, but the point is to apply a function on the value inside as if the container didn't exist
Scott Sauyet
@CrossEye
Sep 22 2015 11:04
@gilligan: I haven't thoroughly grokked it yet, but @scott-christopher's Prism proposal might also help: https://github.com/ramda/ramda/compare/master...scott-christopher:prisms
Tobias Pflug
@gilligan
Sep 22 2015 11:31
oh sweet!!
hemanth.hm
@hemanth
Sep 22 2015 11:31
@raine It's like you remove the contents from the container work on it, put it back to the container, kina right?
Looking for a practical use-case forinvertObj
Tobias Pflug
@gilligan
Sep 22 2015 12:38
@raine as for R.evolve - i realized i also need to manipulate nested properties (i.e R.path not R.prop) so evolve won't work as-is ;/
@raine ah, then again evolve recurses ..
:)
Chet Harrison
@ChetHarrison
Sep 22 2015 15:43
nice @davidchase const now works
Raine Virta
@raine
Sep 22 2015 15:45
@gilligan good to know it recurses, never needed that before
hemanth.hm
@hemanth
Sep 22 2015 16:07
looking for a use case for R.invertObj
Martin Algesten
@algesten
Sep 22 2015 16:54

trying to come up with something point free for this one

attr  = (k,v) ->
    if isboolattr(k) then (if v then "#{esca(k)}" else '') else "#{esca(k)}=\"#{esca(v)}\""

it’s part of writing out html tags where the arguments may be “bool” kind (without a value). but anything i do just ends up with lots of R.ifElse and I actually have to consider both k and v. which could be solved with a tuple and head/last. but it doesn’t get more concise than I already have. anyone else got an idea?

Jethro Larson
@jethrolarson
Sep 22 2015 17:48
http://www.cbloom.com/rants.html library writing learnings
Scott Sauyet
@CrossEye
Sep 22 2015 17:56
@algesten: why points-free? Curiosity? Or does it serve some important need?
Martin Algesten
@algesten
Sep 22 2015 18:09
@CrossEye not really. it may be that I found a golden hammer and suddenly everything looks like a nail.
Scott Sauyet
@CrossEye
Sep 22 2015 18:30
I'm not really a Coffeescript user, but doing the same in ES6 with a nested ternary doesn't look bad at all to me. Any points-free alternative would almost certainly look worse.
Scott Sauyet
@CrossEye
Sep 22 2015 18:36
David Chase
@davidchase
Sep 22 2015 18:45
@ChetHarrison thanks :D
Martin Algesten
@algesten
Sep 22 2015 18:49
@CrossEye thanks!
ternary operator is one of the few things I think is worse in coffee. if-then-else is not as terse and is harder to read.
Jethro Larson
@jethrolarson
Sep 22 2015 21:03
R.ifElse rarely looks better too. I may try using R.cond more often, maybe that'll be nicer
wonderdogone
@wonderdogone
Sep 22 2015 22:12
does a method exist to "insert at every" specified keys of a list?
Scott Sauyet
@CrossEye
Sep 22 2015 22:56
@wonderdogone: not quite following. Could you give sample input and output?
wonderdogone
@wonderdogone
Sep 22 2015 23:06
@CrossEye so basically insert at say every interval of two key positions like
[
{
locale: 'some',
value: 'value'
},
{
locale: 'some',
value: 'value'
},
{
locale: 'some',
value: 'value'
},
{
locale: 'some',
value: 'value'
},
{
locale: 'some',
value: 'value'
}
]
into [
{
locale: 'some',
value: 'value'
},
{
locale: 'some',
value: 'value'
},
{
locale: 'thinginserted',
value: 'thinginserted'
},
{
locale: 'some',
value: 'value'
},
{
locale: 'some',
value: 'value'
},
{
locale: 'thinginserted',
value: 'thinginserted'
},
{
locale: 'some',
value: 'value'
}
]
Scott Christopher
@scott-christopher
Sep 22 2015 23:11
@wonderdogone I believe the closest thing in Ramda at the moment would be intersperse, however that adds the value between every entry in the list, rather than every N entries.
David Chambers
@davidchambers
Sep 22 2015 23:15
@wonderdogone, you might be able to use R.splitEvery as the first transformation in a pipeline.
wonderdogone
@wonderdogone
Sep 22 2015 23:20
yea im doing splitevery.map.insert right now