I think

`Tuple`

might be lying about being `Applicative`

in ramda-fantasy
```
coffee> RF.Tuple.of(R.identity).ap(RF.Tuple([1], [2]))
/home/joneshf/node_modules/ramda-fantasy/src/Tuple.js:27
throw new TypeError(display + " must be a semigroup to perform this
```

i don't think you can implement

`of`

this way.
or even at all in js.

I think im going to have a go at moving more tests over to jsverify again

@joneshf : It looks like it is following the Haskell definition of applicative for a tuple, where given

`(a, x)`

and `(b, y)`

, `a`

and `b`

are `mappend`

ed together (requiring the first elements of each tuple to be a semigroup) while `x`

is applied with `y`

.
Though that example expects the first element to also be a monoid, such that it

`pure`

/`of`

can initialise it using `mempty`

/`empty`

.
yeah, that's the problem. there's no compiler implicitly creating and passing around the

`Monoid`

in js. So `of`

cannot be implemented this way.
`map`

, `apply`

and `chain`

should be fine though
are you saying this implementation is wrong, or that

`Tuple`

cannot be applicative?
(in js)

hmmm

```
_Tuple.prototype.ap = function(m) {
ensureConcat([this[0]]);
return Tuple(this[0].concat(m[0]), this[1](m[1]));
};
```

the latter

the implementation can do whatever it wants, but it's not law abiding

in your example

`m`

is a function, so it doesn't `concat`

but the second item in the tuple must be a function for

`ap`

well function not having

`concat`

is another thing that could be fixed, but that's a discussion for another time.
correct

yes, i'm just catching up on the conversation so far

`ap`

still gives you a law abiding `Apply`

k

yes, if i have

`Tuple([], function f(x) { return x; })`

, i can `ap`

with it
but i see how

`of`

is borked
could we implement

`of`

in terms of Identity? e.g. `of = function(x) { return new Tuple(new Identity(x), new Identity(x)); }`

or does that that kick the problem down the road a bit

yeah

the second part

it actually is equivalent to what's in there now

maybe there's a way to use the dynamicism to have some universal monoid...

though, that'll probably cause problems elsewhere

Another option is to change

`ap`

, `chain`

and `map`

to match semantics of `of`

but i think you are better off not doing that

ok, so simplest thing may be to just uncheck the

`Apply`

box for `Tuple`

`Applicative`

it's still a valid

`Apply`

right, apologies

Is there something like range, which takes a function for each step.

(e.g. for generating dates between start and end dates)

wouldn't you just

`map`

over the range?
i've just start and end dates, which I'm going to process with moment.js

ideally their recur plugin wouldn't suck :-/

I could do this with reduce (looking at the last element)

can you provide some sample input output?

let's simplify this to (1, 10) => [2, 4, 6. 8] (but not through range and filter/reject :) )

why not use range, or filter?

it's LS but which one do you think is more readable? http://git.io/vIcQZ the difference is basically that in the first one the first level is part of the recursive function

because I'm not dealing with numbder

numbers*

okay

what operations do you expect numbers and dates to share?

I'm using numbers just to simplify things here, in practice, my (current) setup is something like this:

- ES6 generator function takes a start-date plus the step argument (e.g Date.now, "1 day")

i think @buzzdecafe 's suggestion is probably the easiest

- into([], takeWhile(d => { ... checking end-date }), myGeneratorFunction(start, inc))

you should be able to just map over the range you generate.

The thing is I don't have the range (it's what I'm trying to generate), so there's nothing I could map over

let me sketch up something with js dates.

```
var startMoment = ...
var interval = ...
R.map(function(x) { return startMoment.add(x, 'days'); }, interval);
```

oh

i see

well there's a few ways to go about that

```
function interval(low, high, step) {
var stepped = R.pipe(R.modulo(R.__, step), R.eq(0));
return R.filter(stepped, R.range(low, high));
}
```

or I think...

```
function interval(low, high, step) {
return R.map(R.mulitply(step), R.range(low, high / step));
}
```

thanks, but I cannot use something like R.range :(

my "range" is just two iso strings

start and end

and it should "map" to an array of dates

what you have here is basically a version of R.range that takes a step argument

i think i don't fully understand the problem

If i'm reading this correctly.

can you provide some inputs and outputs?

sec

I'm having troubles with ES6 generators in the repl

look here, and look at the alerts (ignore the output because, apparently, ES6 generators are broken in REPL): http://bit.ly/1ImEkDM

does that work?

for whatever reason I get the same date repeated

but should have worked, I think.

what about this solution isn't what you're looking for?

well, first, it doesn't work for whatever reason :-/ The takewhile function gets the right dates, but the collected values are all the same (the last value yielded)

secondly, while(true) is ugly :)

oh, nvm, the first problem is my stupidness

it's the same object after all. I don't clone it

so the only thing I don't like about this is the usage of while, I guess, plus it feels like I'm missing something generic that could be leveraged here.

what would you prefer instead of

`while`

?
Some infinite stream abstraction I guess.

`generateDates`

is your infinite stream. just so happens to be implemented with a `while`

@CrossEye excellent, thanks!