-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 foldMap/compile FunctionK to Free companion #1411
Conversation
Current coverage is 92.01% (diff: 90.00%)@@ master #1411 diff @@
==========================================
Files 240 242 +2
Lines 3608 3820 +212
Methods 3540 3751 +211
Messages 0 0
Branches 67 69 +2
==========================================
+ Hits 3308 3515 +207
- Misses 300 305 +5
Partials 0 0
|
👍, but the names seem potentially a little confusing given that they reverse the usual order of arguments. I'm not sure that something like |
This seems basically good to me. Two questions though:
|
@non yeah, when adding these I noticed we were somewhat inconsistent in Free and FreeT. I made FreeT use the standard in the FreeT file. Should I add a duplicate name or rename interpret to compile in FreeT? If we want to make such a change, sooner is better, right? |
Yeah for now let's add a duplicate name, deprecate the non-standard one, and call it a day. |
* Use FunctionK instead of ~> alias in FreeT * Rename interpret in FreeT to compile for consistency with Free
👍 once things are green |
FWIW -- I'm fine with merging this despite not having a test to cover the deprecated method. |
@non Yeah, we could define the new one in terms of the old, but then that's just another thing to do when we remove it. Having it uncovered is also a good motivation to get rid of it as soon as possible, too. :) |
Call me reckless but a deprecated method that just redirects to another is
|
This came up for me in Free usage. We actually didn't want to call
foldMap
but to build anotherFunctionK
.Note, an interesting corollary to noting that Free converts a
FunctionK[S, M] => FunctionK[Free[S, ?], M]
and noting that we always have vialiftF
aFunctionK[M, Free[M, ?]]
then if you have some code that requires complex recursive flatmaps, you can always first convert everything toFree
via liftF, then in the end use theMonad.tailRecM
along withfoldMap(FunctionK.id)
. So, in it seems that many classes of recursion, as long as you don't change the Monad, are covered by implementing tailRecM.