Skip to content

Simplify the representation of the Free monad.#938

Merged
runarorama merged 4 commits into
scalaz:series/7.2.xfrom
runarorama:FreeCoyoneda
May 29, 2015
Merged

Simplify the representation of the Free monad.#938
runarorama merged 4 commits into
scalaz:series/7.2.xfrom
runarorama:FreeCoyoneda

Conversation

@runarorama

Copy link
Copy Markdown
Member

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

@runarorama

Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@jedws

jedws commented May 19, 2015

Copy link
Copy Markdown
Contributor

lgtm

Comment thread core/src/main/scala/scalaz/Free.scala Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Value is lazy here but eager in Return.

@aloiscochard

Copy link
Copy Markdown

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 Free coyoneda Simplify the representation of the Free monad. May 19, 2015
@vmarquez

Copy link
Copy Markdown
Member

Looks good.

runarorama added a commit that referenced this pull request May 29, 2015
Simplify the representation of the Free monad.
@runarorama runarorama merged commit 9148602 into scalaz:series/7.2.x May 29, 2015
@runarorama runarorama deleted the FreeCoyoneda branch May 29, 2015 13:23
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