These are chat archives for ramda/ramda

Feb 2017
David Chambers
Feb 13 2017 00:22

Cross-post from the Sanctuary room:

:heart: sanctuary-js/sanctuary#332 :heart:

Feb 13 2017 00:57
@kwijibo, @alex-deas here’s my attempt at separating out the validation and then delegating to it in the type ctor, using paldepind’s union-types. I’m still not happy with it, mainly because the dependent types constraint of min < max forces me repeat logic that I’d rather union-types be handling. Any feedback appreciated:
const Any = always(true);

function Range(min, max) {
  const res = Range.validate(min, max);
    Range: () => res,
    InvalidMin: () => {throw 'Invalid min'},
    InvalidMax: () => {throw 'Invalid min'},
    MinGreaterThanMax: () => {throw 'Min cannot be greater than max'}
  }, res);

Range.RangeValidationResult = Type({
  Range: [Number, Number],
  InvalidMin: [Any],
  InvalidMax: [Any],
  MinGreaterThanMax: [Number, Number]

Range.validate = function(min, max) {
  const Result = Range.RangeValidationResult;
  return (!isNumber(min)) ? Result.InvalidMin(min) :
         (!isNumber(max)) ? Result.InvalidMax(max) :
         (min > max)      ? Result.MinGreaterThanMax(min, max) :
                            Result.Range(min, max);
Gabe Johnson
Feb 13 2017 14:36
@davidchambers :tada:
Mick Dekkers
Feb 13 2017 19:53
I'd like to use the return value of R.view in an object destructuring assignment, but the problem is that it could be null (and thus cause a TypeError). e.g.:
const { foo, bar } = R.view(foobarLens, data)
Any advice? I'd prefer not to wrap it in a try/catch or have an if statement check the return value first because I'd like to keep the code concise.
Keith Alexander
Feb 13 2017 19:55
R.defaultTo({}) ?
Mick Dekkers
Feb 13 2017 19:57
Nice, thanks guys! :smile:
Feb 13 2017 21:22
@joneshf "What I'm saying is, it's okay to not stretch the "container" metaphor..." so I think you're saying that a metaphor is like a burrito: trying to stretch it is a bad idea
Rick Medina
Feb 13 2017 21:25
:laughing: ohh, I would so much love a burrito I could stretch and eat forever.
Brad Compton (he/him)
Feb 13 2017 21:30
Feb 13 2017 22:54
hi guys
how can I make this bit simpler?
first map is applied to Future from ramda-fantasy. Second map is applied to Maybe, also from ramda-fantasy
Alex Deas
Feb 13 2017 22:58
So you have a [Future[Maybe[A]]] and you want to map over it to construct what?
Feb 13 2017 22:58
I want to
umm well.. this.props.fetchedData actually dispatches a redux action
and sends off the data that is inside that [Future[Maybe[A]]]
so I have something like this:
        Future.of(likesToProjects => [likesToProjects])
                .map(compose(Maybe, prop('data'))))
I specifically need likesToProjects to be inside an array
at the moment the server returns an object
I will be using .ap on other Futures soon and basically for the end result I want to have a bunch of data inside an array
so it would look something like this:
        Future.of(likesToProjects => someOtherData => [someOtherData, likesToProjects])
                .map(compose(Maybe, prop('data'))))
hope that makes sense
Alex Deas
Feb 13 2017 23:12
Sorry, can't seem to wrap my head around it; and I don't have a pen on me at the moment (I usually need one to think) - I'll take a look at it tomorrow morning if someone else doesn't come up with an answer before then
Feb 13 2017 23:12
no problem :)
Hardy Jones
Feb 13 2017 23:23
@dtipson meta
Rick Medina
Feb 13 2017 23:29