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

Revisiting application structure #4

Merged
merged 9 commits into from
Aug 16, 2020

Conversation

felixmulder
Copy link
Owner

@felixmulder felixmulder commented Aug 7, 2020

Here's a draft of my thoughts on us going to the MonadTransControl approach for MTL.

Here's TODOs:

  • Attribute approach to Pepe and get a bit more background on where he came up with it, from "the old place"?
  • MonadTransControl vs only MonadTrans?

@felixmulder
Copy link
Owner Author

Going sailing tomorrow, so published an initial version of this. Happy to update the attribution paragraphs if there's something else you think I should put there :)

writing/2020-08-08-Revisiting-application-structure.md Outdated Show resolved Hide resolved
mechanical boilerplate. This behavior looks like it could be captured by a
typeclass (or two).

One of our engineers, [Moisés](https://twitter.com/1akrmn), who previously
Copy link

Choose a reason for hiding this comment

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

definitely not my credit to take! This approach was pretty much in place when I joined the team where I saw it. I believe @pepeiborra, @vapourismo and @adamse might have a better picture of the story behind it

Choose a reason for hiding this comment

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

When I joined Strats in Jan 2017, the codebase was already making heavy use of type classes for individual effects, e.g. MonadTime, MonadDelay, MonadLog, etc. but there was no solution to the n^2 problem. Monad transformers were providing instances for all the effects, relying on deriving to avoid as much boilerplate as possible. Alexis article takes this approach to the extreme.

I made the point that introducing a new effect class required adding it to the deriving lists of all N transformers, which made engineers unwilling to add effects. and the approach could not scale. My solution to this was the passthrough instance, which requires a MonadTransControl transformer (or MonadtTrans for non-scoped effects). Since all ReaderT transformers are in MonadTransControl by definition unless the environment mentions the base monad, the codebase quickly gravitates towards ReaderT in order to avoid having to write instances manually.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thanks a lot for the insight! Added it to the post and linked to your comment 🙌

@felixmulder felixmulder merged commit 378ecfb into dev Aug 16, 2020
@felixmulder felixmulder deleted the revisiting-application-structure branch August 16, 2020 10:18
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.

3 participants