Skip to content
0:00 / 0:00

#monads#monadtransformers#haskell

ZuriHac 2016: Monad Homomorphisms

Google TechTalks

349K subscribers • 62 videos on Hallway

YouTube
  • Recommended by 1 person: 1 in engineering communities.
  • Presented by Edward Kmett

Advanced. Deep dive for people who know the field.

5.3K views10 years ago1 recommendation

Programming languagesSoftware designHaskellFunctional programmingPerformance and optimization

Edward Kmett explores monad homomorphisms as a solution to the pathological performance problems caused by traditional monad transformer libraries.

A Google TechTalk, July 23, 2016, presented by Edward Kmett ABSTRACT: The way that we use the monad transformer library today leads to code that has pathological performance problems. Can we do better? wiki.haskell.org/ZuriHac2016

Why it's here

1 person recommends this

What people say. Recommended as a brilliant talk on solving performance issues in Haskell's monad transformer library.

Moments people linked to

u/edwardkmettin r/haskell • Recommends

Edward Kmett - Monad Homomorphisms - Google Tech Talk @ ZuriHac 2016

u/tomejaguarin r/haskell • Mentions

Monad transformer optics Yesterday I asked a question about a certain form of commutation operation for monad transformers. I've followed it a bit further and (re)discovered that you can make optics for monad transformers. See the source file on my GitHub account for full details, but as a taster, ``` type a ~> b = forall r . a r -> b r type LensLike f s (t :: * -> *) a b = (a ~> f b) -> (s ~> f t) type ASetter s t a b = (a ~> IdentityT b) -> (s ~> IdentityT t) lensIdentity :: (MFunctor t, Monad a, Monad b) => (a ~> t b) -> (IdentityT a ~> t (IdentityT b)) affineState :: (MonadTrans t, MFunctor t, Monad (t (StateT s b)), Monad a, Monad b) => LensLike t (StateT s a) (StateT…

u/edwardkmettin r/haskell • Mentions

On “What is the type signature of AppT people usually use?”

…sy lens instances. So, for me, the usual type of `App` is just `m` with a pile of constraints on it as talked about by George here. In the cases where dispatch for the more polymorphic type signature becomes a performance bottleneck, I can always manifest a particular monad at the last second and define the embedding of it with something like link to this video…

u/edwardkmettin r/haskell • Mentions

On “Typeclass Lenses”

> I wonder if you could do something cool with monad transformers though. link to this video directly tackles this, and the follow up link to this video takes it in a slightly different direction.

u/edwardkmettin r/haskell • Mentions

On “Expected performance drop while using monad transformers?”

…step in `m` regardless of what monad `m` is, and the code doesn't get to know. Liberal application of INLINE might help, but it may not. I gave a talk at Zurihac over the summer about the sort of issues that transformers face, ways to fight the transformer performance tax, and argued in the general direction of a way folks might address it here: link to this video That said, there is no silver bullet here. Effect systems rule out a number of common monad transformers, pay for each 'run' completely separately, or silently lie about the ability to implement a handler and comply with the laws of the 'effect', depending on if they are CPS'd or not. Monad transformers pay for lots of unnecessary work…

u/Iceland_jackin r/haskell • Mentions

On “Proposal/MonadOfNoReturn”

What if we treated them as extensible records where restricting (`-`) removes methods type Apply f = (Applicative f - pure) type Pointed f = (Applicative f - (<*>)) -- Before Semigroup/Monoid proposal type Semigroup s = (Monoid s - mempty) type Semigroupoid cat = (Category cat - id) A similar problem is `MonadReader` / `MonadWriter` (discussed here, here by Edward Kmett), separating algebraic operations (`tell` / `ask`) from non-algebraic (`listen` / `pass` / `local`) ones. This enables us to define more instances: type MonadAsk e m = (MonadReader e m - local - reader) type MonadTell w m = (MonadWriter w m - pass - writer - listen) How would this work?…
4View on Reddit

u/phadejin r/haskell • Mentions

On “Is there such a thing as higher-ranked constraints?”

transform :: Monad m :- Monad (t m) link to this video But, yeah, it would be nice not to need to pass such constraints explicitly.
3View on Reddit

u/edwardkmettin r/haskell • Mentions

On “Recommended way to use monad transformers, MTL-style effects or alternatives”

I gave a talk on my sort of in-progress thoughts on what might be better at ZuriHac last year: link to this video It hasn't yet firmed up into an approach I might endorse though. My usual rule of thumb is to write all the code down using as generic constraints as possible. Distilling a little idea from the talk: If I'm calling something small that needs to be fast and needs minimal state, and no other constraints I can always manually "zoom" in my getting the bit of state out of my larger monad, calling the function with just runState whatever MyLittleState and swizzle the state back into my larger context. I find this tends to be a very small percentage of my code. A few manually written monad hom…

u/edwardkmettin r/haskell • Mentions

On “Using (functor) profunctor optics to alleviate the n × m instances problem in MTL”

I gave a talk on them at Monadic Warsaw at some point, before I pivoted and gave a talk on monad monomorphisms at Zurihac a couple weeks later.

u/edwardkmettin r/haskell • Mentions

On “Monad Transformers and Effects with Backpack”

Those functions are monad (mono)morphisms: link to this video

u/fieldstrengthin r/haskell • Mentions

On “Name for the style of programming in https://lexi-lambda.github.io/blog/2016/06/12/four-months-with-haskell/ ("typeclasses can emulate effects")”

Also worth a mention that Ed Kmett discussed the problem as motivation in this talk.
2View on Reddit

u/T_S_in r/haskell • Mentions

On “Learning Haskell as a Category theorist”

Here's some good use of category theory applied to Haskell. In this case monad homomorphisms: link to this video

u/T_S_in r/haskell • Mentions

On “Learning Haskell as a Category theorist”

Here's some good use of category theory applied to Haskell. In this case monad homomorphisms: link to this video

u/edwardkmettin r/haskell • Mentions

On “Quantified Class Constraints (pdf)”

I used the `Lifting Monad` approach for link to this video (In particular I needed a tensor for the category of monad transformers for the precursor to that talk from the week before.)