Remix.run Logo
shakadak 6 hours ago

You've mentioned list comprehensions, map, and filter, so I suppose you mostly used these concepts with lists/arrays.

One question you could ask yourself is, how could you reproduce list comprehensions without special syntax ?

Another way to view monads is by following the types. With map, you can chain pure functions from one type to another to be applied on lists (hence the (in -> out) -> ([in] -> [out]) ) . How would you do that chaining with function from one type to another but wrapped in a list ( (in -> [out]) -> ([in] -> [out]) ) ?

Then you can think about how it could be applied to other types than lists, for example, nullable/option types, result types, async/promise types, and more hairy types that implement state, reading from an environment, etc...