Zulip Chat Archive

Stream: Is there code for X?

Topic: Why List Monad is in mathlib and not in core ?


Alfredo Moreira-Rosa (Dec 23 2025 at 14:14):

I was wondering why List don't have an instance of Monad in core.
I'm sure this has already been asked, but i couldn't find an answer in zulip history.
Is it to evoid misunderstanding when using do notation ?

Henrik Böving (Dec 23 2025 at 14:24):

You're looking for #general > question: why List is nolonger Monad? @ đź’¬

Alfredo Moreira-Rosa (Dec 23 2025 at 15:00):

Thanks, so mainly for perf issues with do notation.

cmlsharp (Dec 24 2025 at 23:43):

I haven’t given it much thought concretely but would it be possible to create an Iterator monad?

cmlsharp (Dec 24 2025 at 23:44):

Or rather, not just “is it possible” but “would that be desirable”

It feels like the internal iterator state being part of the type might make it not possible though

Jakub Nowak (Dec 25 2025 at 00:23):

cmlsharp said:

I haven’t given it much thought concretely but would it be possible to create an Iterator monad?

That could be nice. Kinda like generator functions in python or c++.

cmlsharp (Dec 25 2025 at 02:30):

Yeah exactly, or the list monad in Haskell (iterators are basically just lazy lists)


Last updated: Feb 28 2026 at 14:05 UTC