Live data from Hacker News

Which monads Haskell developers use: An exploratory study

sciencedirect.com

11–14 of 14 posts

Re: Which monads Haskell developers use: An exploratory study

#11
post #2

A big advantage of the monad abstraction is that you can define custom monads to suit your business cases, but then reuse a lot of existing functionality with those monads. So looking at which "standard" monads are most popular only tells half the story.

This is probably true of every mathematical abstraction in wide usage. A big advantage of the probability abstraction (as a "partial knowledge" concept supported by Dutch Book/sure bet arguments) is that you can define probability distributions to suit your business cases but then reuse a lot of existing algorithms and even theorems (cutting down on computation).

> This is probably true of every mathematical abstraction in wide usage.

After learning the categorical definition of monads and how they arise in math, I've noticed that programmers tend to have a very operational view of monads, when they are more general than the examples in functional programming.

A good example that came up in a propositional logic class was[0]

[0] https://en.wikipedia.org/wiki/Closure_operator

Re: Which monads Haskell developers use: An exploratory study

#12

I used most commonly IO and State monads. but I didnt write any Haskell code for like 4 years now. So stuff could change. Maybe GHC got fixed ;)

This study is about the usage of monads from the monad transformer library (mtl) across Hackage.

Re: Which monads Haskell developers use: An exploratory study

#13
post #10
post #9

Earlier quoted context omitted.

> compositional and performance advantages Compositional sure, but performance? Care to elaborate?

I'd point you to Oleg Kiselyov's page on Extensible Effects[0]. Here's a quote: Thanks to the Freer monad construction and the representation of the continuation as an efficient sequence structure, extensible effects have good performance even for relatively short monad stacks, and algorithmically better performance than monad transformers for longer stacks. Essentially the performance improvement comes when you need…

Not sure what the status of the project is, but work on https://github.com/hasura/eff is supposed to improve the performance even more!

Re: Which monads Haskell developers use: An exploratory study

#14
post #3

Haskeller here, some observations: - Not surprised that the state monad is the most commonly used one, it essentially acts as an escape hatch to write more imperative-looking code - List monad least used, probably due to the fact that Haskell has list comprehensions - Continuation monad is second least used, much like how many programmers find Scheme's call/cc unintuitive, continuations can be complex conceptually an…

> One ought to be able to express more nuanced side effects such as network/disk access or console I/O

IIRC, this is one of the things that Idris brings to the table.

Post reply on HN