SodiumFRP / sodium

Sodium - Functional Reactive Programming (FRP) Library for multiple languages
http://sodium.nz/
Other
851 stars 140 forks source link

Order of parameters and type inference #90

Closed ziriax closed 8 years ago

ziriax commented 8 years ago

I noticed that Cell.lift first takes a lambda argument, then the cells. Other methods like snapshot seem to take the cell first, then the lambda. Wouldn't it be better for type inference and uniformity that all methods have their input cells and streams as first parameters, followed by the lambda?

jam40jeff commented 8 years ago

Yes, I believe this would make more sense for languages which don't allow for partial function application, such as Java. This is how I did it for the C# version.

the-real-blackh commented 8 years ago

Yes, it would be good to improve this. The only problem is the book, so for Java I will need to change the book as well. I think this can be done, so I'll see what I can do. This is one of many things I would have liked to have got done but ran out of energy for.

the-real-blackh commented 8 years ago

I've made the following API changes to the Java version and released it on Maven Central as sodium-1.1.0.

1. Deprecate Cell.lift(f, a, b) replacing it with a.lift(b, f)
2. Add snapshot variants that take up to 5 cells.
3. Add Stream.mapTo() that allows you to map a stream to a constant value.

I am not sure if a.lift(b, f) is what you had in mind, but I think this is the way to do it because then it's identical to snapshot.

ziriax commented 8 years ago

Thanks!