Skip to content
0:00 / 0:00

#fused-effects#effectsystems#monadtransformers

"Building Haskell Programs with Fused Effects" by Patrick Thomson

Strange Loop Conference

88K subscribers • 114 videos on Hallway • Conference channel

YouTube
  • Recommended by 1 person: 1 in engineering communities.
  • Presented by Patrick Thomson

Intermediate. Assumes working knowledge.

19K views7 years ago1 recommendation

Programming languagesSoftware designHaskellFunctional programmingSoftware architecture

Patrick Thomson explains how effect systems like fused-effects provide a compositional alternative to monad transformers in Haskell.

Haskell is a purely functional programming language: by default, Haskell functions do not cause side effects such as system I/O, nondeterminism, or exception handling. As such, Haskell programs are generally expressed in terms of monad transformers, which provide the facility to compose different side effects into a single interface powerful enough to express the programmer's needs. The monad transformer library, mtl, is mature and powerful, but complicates and in some cases constrains the construction and generalization of user-specified monads. A class of libraries known as 'effect systems' have emerged in an attempt to solve the problems associated with monad transformers. Effect systems provide a compositional approach to program construction, generally using a single monadic type specialzed with a programmer-provided list of capabilities. Effect systems are more powerful and flexible than monad transformers, but their adoption in industry has been minimal, due both to their incompatiblity with mtl and their historically poor performance. The new fused-effects library changes the status quo: it provides an extensible and flexible vocabulary for program construction, yielding a more expressive interface than mtl without sacrificing any performance characteristics. I'll describe the history of effect systems, outline the tradeoffs associated with programming with effects, and demonstrate the use of fused-effects in practice. Patrick Thomson GitHub, Inc. @importantshock Patrick is a senior engineer on GitHub's Semantic Code team, building systems to understand and analyze the corpus of code on GitHub. He enjoys peaceful countryside walks and loud rap shows.

Why it's here

1 person recommends this

What people say. Recommended as a clear introduction to the fused-effects library and how it compares to traditional monad transformers.

Moments people linked to

u/n00bombin r/haskell • Recommends

"Building Haskell Programs with Fused Effects" by Patrick Thomson

u/patrick_thomsonin r/haskell • Mentions

ANN fused-effects v.1.0.0.0 `fused-effects` is an effect system for Haskell applications emphasizing speed, rigor, and ease-of-use. It powers several Haskell applications, such as `semantic`, the `aura` package manager, and the Komposition video editor. This release reorganizes the module hierarchy provided by the library, separating the definitions of effects from the carrier types that specify an effect’s semantics. It also decomposes the `Error` effect into separate `Catch` and `Throw` effects, and similarly splits the `NonDet` effect into `Empty` and `Choose` effects. For more detail on what `fused-effects` is or why you might want to use it, you can check the README on GitHub, or…

u/patrick_thomsonin r/haskell • Mentions

On “Any resources for software architecture in Haskell?”

This is too broad of a question to cover adequately in a Reddit comment, but here’s a hand-wavy description of my methodology: 1. Do the simplest thing possible. Sometimes the best solution is functions in IO. But if you start threading context parameters everywhere, or returning tuples to constitute state modifications, or you’re drowning in ill-encapsulated complexity, reach for an effect system. 2. Identify the effects you need for your program. Most programs that interact with the real world are going to need `State`, `Reader` and `IO`, but you may also need tracing, logging, nondeterminism, concurrency, etc. 3. Express those effects with whatever effect system you use. For mtl, this is…

u/Faucelmein r/haskell • Mentions

On “"Building Haskell Programs with Fused Effects" by Patrick Thomson”

Very informative talk! Around 20:50, it is mentioned that explicit control about the ordering of effects is difficult with MTL (for example having a state above a non-determinism effect, and another below, so that one will be per-branch and the other shared across all branches). In what sense is the situation better with fused-effects? Does the advantage consist in being able to define separate `State` effects that can be interpreted in different order, or does the library also allow you to specify an explicit ordering of "uninterpreted" effects? (**edit**: looking at the haddocks, it seems you can force an order by explicitly specifying the "sig".)
7View on Reddit

u/patrick_thomsonin r/haskell • Mentions

On “Are Monad Transformers practical in Haskell?”

I'm one of the maintainers of `fused-effects`. I gave a talk about its origins, why our use case called for algebraic effects over `mtl`, and what its upsides and downsides are. The executive summary is that `mtl`, using the monad transformers from `transformers`, is the _de facto_ effect system for Haskell, but its implementation leads to a few downsides: for example, `mtl` requires significant - O(n^2) - boilerplate if you need to have two stateful values in a given computation that are accessed with different semantics. Not everyone runs into this problem, and if you haven't, `mtl` will probably fit your needs fine. However, for applications that are hitting `mtl`'s pain points or tha…

u/dustingetzin r/Clojure • Mentions

On “Best talk since Maybe Not?”

FRP - https://blog.janestreet.com/breaking-down-frp/ - https://www.janestreet.com/tech-talks/seven-implementations-of-incremental/ - https://github.com/gelisam/frp-zoo#readme - Conal Elliott - https://kefirjs.github.io/kefir/ - https://github.com/leonoel/missionary Algebraic effects – this stuff is really raw, you'll need to know haskell up through monad transformers - https://github.com/fused-effects/fused-effects - link to this video - https://degoes.net/articles/modern-fp https://degoes.net/articles/modern-fp-part-2 - https://zio.dev/ - Oleg Kiselyov - https://leanpub.com/functional-design-and-architecture - https://twitter.com/jdegoes - https://twitter.com/lexi_lambda

u/maayonin r/haskell • Mentions

Effectfull programs vs theorem provers [video In the video the author says programs that do not produce any effects are either no operation or theorem provers. Under what context does a program become a theorem prover ?
1View on Reddit