These are chat archives for ramda/ramda

14th
May 2015
Chet Harrison
@ChetHarrison
May 14 2015 04:22
I think I have a monadic plan
Raine Virta
@raine
May 14 2015 13:02
would be grateful for some feedback on the README
https://github.com/raine/ramda-cli
Brandon Wilhite
@JediMindtrick
May 14 2015 13:52
If I get time, I'll take a crack at it this weekend. I'd be a good test of a "slightly-clueful" user :)
I like the idea for sure
Raine Virta
@raine
May 14 2015 14:36
cheers, let me know if you encounter something weird
Simon Friis Vindum
@paldepind
May 14 2015 18:09
Does something like this exist already? Or is it a really stupid idea?
It's a tiny library to create types like this:
var Point = Type({Point: [isNumber, isNumber]});
var Shape = Type({Circle: [isNumber, Point],
                  Rectangle: [Point, Point]});
var area = Type.case({
  Circle: (radius, _) => Math.PI * radius * radius,
  Rectangle: (p1, p2) => (p2[0] - p1[0]) * (p2[1] - p1[0])
});
David Chambers
@davidchambers
May 14 2015 18:34
@paldepind, that looks neat! I’m not aware of a library quite like that.
Jethro Larson
@jethrolarson
May 14 2015 18:40
Is highlandjs the preferred lib for working with steams? As opposed to Rxjs or bacon?
Simon Friis Vindum
@paldepind
May 14 2015 18:42
@jethrolarson I've created Flyd. Everything is obviously a matter of preference. But you're not going to find a FRP library that match the style of Ramda as well as Flyd.
@davidchambers I'm glad you find it neat :)
Kevin Wallace
@kedashoe
May 14 2015 19:20
@paldepind there was a discussion on immutable-js along those lines: https://github.com/facebook/immutable-js/issues/407#issuecomment-86134826
Simon Friis Vindum
@paldepind
May 14 2015 19:24
@kedashoe Thanks for the link. It looks quite similar. But for records instead of data types.
Hardy Jones
@joneshf
May 14 2015 19:41
@paldepind seems similar to daggy: https://github.com/puffnfresh/daggy
I think it's a great idea
Simon Friis Vindum
@paldepind
May 14 2015 19:49
@joneshf Indeed! It looks quite a bit like it. The cata function looks a lot like my case. But it names fields only. It doesn't do runtime type checking.
Hardy Jones
@joneshf
May 14 2015 19:51
can you create unit types with it?
var Foo = Type({Foo: []});
or does it have to have a value?
Simon Friis Vindum
@paldepind
May 14 2015 19:54
Yes. You can do that!
An example:
var Action = Type({Walk: [], Run: []});
function advance(pos, action) {
  return Type.case({
    Walk: function() { return pos + 5; },
    Run: function() { return pos + 15; },
  });
}
Hardy Jones
@joneshf
May 14 2015 19:57
very nice
Simon Friis Vindum
@paldepind
May 14 2015 20:01
:)
Hardy Jones
@joneshf
May 14 2015 20:02
what happens if you pass the wrong thing to something that doesn't have a validator?
like:
var Shape = Type({Circle: [isNumber, Point],
                  Rectangle: [Point, Point]});
var circle = Shape.Circle(10, 3);
Simon Friis Vindum
@paldepind
May 14 2015 20:04
In that example you're passing a type instead of a validator. Then the passed value is checked against the type. The above example would throw an error.
Hardy Jones
@joneshf
May 14 2015 20:08
ah
Simon Friis Vindum
@paldepind
May 14 2015 20:12
The readme is not really clear about that :(
Jethro Larson
@jethrolarson
May 14 2015 21:08
http://tomasp.net/blog/2015/against-types/index.html found this interesting. Since we're talking about types
Hardy Jones
@joneshf
May 14 2015 21:31
I only skimmed it, but i pretty much agree.