Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transform and subflatMap to OptionT and XorT #571

Merged
merged 1 commit into from
Nov 10, 2015

Conversation

liff
Copy link
Contributor

@liff liff commented Oct 15, 2015

As per gitter discussion; proposing to add transform and subflatMap methods to OptionT and XorT. I suppose they should be in StreamingT as well but it's not currently obvious to me how to go about the implementation.

TODO:

  • agree on the name :)
  • add tests
  • implement for StreamingT?

@ceedubs
Copy link
Contributor

ceedubs commented Oct 15, 2015

Thanks, @liff!

I think you can relax all of the Monad constraints to Functor.

@codecov-io
Copy link

Current coverage is 76.13%

Merging #571 into master will increase coverage by +0.09% as of 86b71fc

@@            master    #571   diff @@
======================================
  Files          159     159       
  Stmts         2066    2070     +4
  Branches        69      69       
  Methods          0       0       
======================================
+ Hit           1571    1576     +5
  Partial          0       0       
+ Missed         495     494     -1

Review entire Coverage Diff as of 86b71fc

Powered by Codecov. Updated on successful CI builds.

@non
Copy link
Contributor

non commented Oct 15, 2015

I'm fine with the names. I agree with @ceedubs that you can relax the constraints. I also think it might be nice to write value.map(f) instead of F.map(value)(f) but that is somewhat subjective.

I'd say you should proceed with the tests and then we can think about how (or if) to make this work for StreamingT 😉

@aryairani
Copy link
Contributor

transform vs subMap? Or is there history behind the names?

@liff
Copy link
Contributor Author

liff commented Oct 16, 2015

Relaxed constraints.

@non, wrt. value.map(f), that would require importing cats.syntax.functor and it doesn't seem to be consistent with the other methods around?

@refried, the only history is in the linked gitter conversation :)

@ceedubs
Copy link
Contributor

ceedubs commented Oct 16, 2015

This looks good to me. I think it's good to merge once it gets some tests.

I think the lack of consistency of where we are using syntax and where we aren't is a bigger issue that we can tackle separately. It's made a bit trickier by the fact that Machinist and Simulacrum currently don't play together very nicely. Hopefully typeclassic saves the day! :)

@non
Copy link
Contributor

non commented Oct 16, 2015

Sure, let's leave my syntax suggestion out of this.

@liff
Copy link
Contributor Author

liff commented Oct 20, 2015

Sorry guys, somewhat busy at the moment; going to get back to this later this week.

@ceedubs
Copy link
Contributor

ceedubs commented Oct 20, 2015

@liff no worries; no rush.

@liff liff force-pushed the topic/subflatMap branch 2 times, most recently from 723b53c to 053b903 Compare November 5, 2015 16:22
@liff
Copy link
Contributor Author

liff commented Nov 5, 2015

Some tests added. Let me know if that looks sufficient.

Implementation for StreamingT still eludes me, unfortunately. It's quite different from these two specimen.

I also feel obliged to add @TomasMikula's comments about Hoist here, for the record.

@TomasMikula
Copy link
Contributor

On that note, both OptionT and XorT can be made Hoists (reference from scalaz: MaybeTHoist, EitherTHoist) and then subflatMap can be implemented in terms of hoist.

@TomasMikula
Copy link
Contributor

And then so can be StreamingT.

@TomasMikula
Copy link
Contributor

It's still open (at least to me) whether there are interesting monad transformers that are not Hoists but have a meaningful subflatMap, but these three are not such.

@ceedubs
Copy link
Contributor

ceedubs commented Nov 5, 2015

👍

I could see Hoist being handy for this sort of thing in the future, but I think these methods are also useful as they are in this PR.

@ceedubs
Copy link
Contributor

ceedubs commented Nov 10, 2015

Sorry for the hassle @liff, but could you please resolve the merge conflict?

@liff
Copy link
Contributor Author

liff commented Nov 10, 2015

Done.

@ceedubs
Copy link
Contributor

ceedubs commented Nov 10, 2015

👍 thanks @liff!

@non
Copy link
Contributor

non commented Nov 10, 2015

Looks good to me. 👍

ceedubs added a commit that referenced this pull request Nov 10, 2015
Add transform and subflatMap to OptionT and XorT
@ceedubs ceedubs merged commit 74acdef into typelevel:master Nov 10, 2015
@liff liff deleted the topic/subflatMap branch April 25, 2016 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants