soabase / soabase-halva

Idiomatic Scala ... in Java
https://github.com/soabase/soabase-halva/blob/master/README.md
Apache License 2.0
81 stars 5 forks source link

Monadic for #18

Closed Randgalt closed 8 years ago

Randgalt commented 8 years ago

Completely re-worked for-comp from work by Alex Piggott. For-comps can now be generated for things other than streams

Randgalt commented 8 years ago

@Alex-At-Home here's the final implementation. I had to make some specific changes. With StreamFor filter() is required as once you start processing a stream you can't add more or you get an exception. So MonadicForImpl now has 2 methods for yielding depending on whether or not fitler() is available. Halva's original For now uses a generated StreamFor internally.

Randgalt commented 8 years ago

@Alex-At-Home have a look at https://github.com/Randgalt/halva/blob/9fa3179a3ff955fdfbe39592e1354b09c3ccb633/halva-test/src/test/java/com/company/FutureForFactory.java to see how the class generator works.

Alex-At-Home commented 8 years ago

Nice! And the generated class is the same as before. That's awesome. What about the multi type case?

(ps Yeah I hadn't gotten around to testing filter, sorry about that!)

Randgalt commented 8 years ago

What about the multi type case?

I need to test that - I'll do that next.

Randgalt commented 8 years ago

@Alex-At-Home fyi - I tried it with your FP example Writer and it worked perfectly.

Randgalt commented 8 years ago

merged