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

Simplify the representation of the Free monad. #938

Merged
merged 4 commits into from May 29, 2015

Conversation

Projects
None yet
6 participants
@runarorama
Member

runarorama commented May 19, 2015

Review by @pchiusano, @vmarquez, @divarvel, and/or @aloiscochard appreciated.

@runarorama

This comment has been minimized.

Member

runarorama commented May 19, 2015

I am a little displeased that x and x.flatMap(pure) don't have the same in-memory representation or the same performance characteristics. A user cannot observe the difference other than with timing, but it seems less than ideal.

Note that this implementation does no walking under Gosubs in flatMap. We have to eat the cost of reassociating binds sooner or later, and here we're opting for later.

@@ -1,95 +0,0 @@
package scalaz.example

This comment has been minimized.

@tpolecat

tpolecat May 19, 2015

Contributor

Would be nice to see this reworked rather than deleted. People seemed to find it helpful.

@jedws

This comment has been minimized.

Contributor

jedws commented May 19, 2015

lgtm

Suspend(value)
/** Return the given value in the free monad. */
def point[S[_], A](value: => A): Free[S, A] = Return[S, A](value)

This comment has been minimized.

@japgolly

japgolly May 19, 2015

Contributor

Value is lazy here but eager in Return.

@aloiscochard

This comment has been minimized.

Contributor

aloiscochard commented May 19, 2015

That is great!

Less is more, I think it makes thing much easier to understand to anyone diving in the code now that there is just a single implementation.

Plus, I was never very comfortable with that arbitrary 500 limit :-)

About the sub-optimal performance concerns of x.flatMap(pure), well it's Scala... personally, I think the trade-off is worth it due to the big abstraction benefit we can see here.

LGTM

@runarorama runarorama changed the title from Free coyoneda to Simplify the representation of the Free monad. May 19, 2015

@vmarquez

This comment has been minimized.

Member

vmarquez commented May 20, 2015

Looks good.

runarorama added a commit that referenced this pull request May 29, 2015

Merge pull request #938 from runarorama/FreeCoyoneda
Simplify the representation of the Free monad.

@runarorama runarorama merged commit 9148602 into scalaz:series/7.2.x May 29, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@runarorama runarorama deleted the runarorama:FreeCoyoneda branch May 29, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment