These are chat archives for ramda/ramda

7th
Aug 2017
Syaiful Bahri
@syaiful6
Aug 07 2017 14:47
@dustinws if i understand correctly your scanP is look like traverse
or maybe foldM
Syaiful Bahri
@syaiful6
Aug 07 2017 14:53
i guess it look like foldM :: Monad m => (a -> b -> m a) -> a -> [b] -> m a
if not then liftA3 + join should be enough to implements that same functionality
Dustin Stiles
@dustinws
Aug 07 2017 16:12

@syaiful6 That looks super close! I'd say that scanP is closer to foldM since traverse only operates on one value at a time, and isn't responsible for "joining" any of the arguments together. (I don't believe you could write compose or pipe in terms of traverse).

Also, please correct me if I'm wrong (I'm definitely not an expert in haskell), but I don't think liftA3 + join would work. The liftA3 part sounds pretty close, as I do need to supply 3 monads as the input parameters, but I get confused at the join part.
Since join :: Monad m => m (m a) -> m a
That only gives the final result, right?

I need access to all intermediate steps of the composition. If I didn't understand your suggestion correctly, would you mind providing a tiny example to show it being used?

@rickmed Thanks for the shoutout!
@gabejohnson I definitely agree that scanP is a much bigger contender. It would be cool to see it in the ramda api, but I realize my implementation has a hard dependency on a specific promise implementation (which the other ramda promise fn's appear to avoid). I'd be happy to re-write in es5 without the Promise dependency and submit a PR if you think ramda could use something like this.
Syaiful Bahri
@syaiful6
Aug 07 2017 17:21
@dustinws i reread your code, look like you need previous result of Monad, so liftA3 can't be used. So, your scanP look like a ways to implements it, or just use Ramda pipeM, but collect the intermediate results on the monad you are working, such ase Writer etc
Jonathan Chang
@jdkschang
Aug 07 2017 17:36

Have a noobie question regarding compose and invoker; In the video examples I’ve seen, the parameters in the invoked function are hardcoded i.e.:

compose(
  slide, 
  animate({left:'10px'}), 
  animate({left:'250px'}),
  jq
  )

Are there ways to pass arguments sequentially similar i.e.:

compose(
  slide, 
  animate(R.__), 
  animate(R.__),
  jq
  )
Jonathan Chang
@jdkschang
Aug 07 2017 17:59

if the last block was assigned

let animateSlide = compose(
  slide, 
  animate(R.__), 
  animate(R.__),
  jq
  )

then calling animateSlide({ left: ‘250px’ }, { left: ‘10px’ }) would result in the same outcome as the initial hardcoded example

Gabe Johnson
@gabejohnson
Aug 07 2017 19:13
@dustinws I think it's definitely worth at least opening an issue about :+1:
Dustin Stiles
@dustinws
Aug 07 2017 22:30
@gabejohnson Good, idea. I opened #2247 for it.
Dustin Stiles
@dustinws
Aug 07 2017 22:45
@jdkschang Functions given to invoker should automatically be curried, so you can use R.__ with them.