Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Could you elaborate on that? What does 'flatMappable' mean in this context?


This is a good explanation:

https://users.scala-lang.org/t/what-is-a-monad-in-scala/4169

It's like... what would you call all types that have a .write() method? Writable right? What would you call all types that have a .dispose() method? Disposable. What would you call all types that have a .flatMap() method? Monad obviously.


That’s because flatMap() is a good name for a particular list operation, but it’s not generic enough to be a good name for the corresponding monad operation.

I’m not sure there is a good name for the monad operation. Sometimes it’s called ‘bind’ but what does it bind?

I suppose you could call it ‘then’ like when working with Promises.


Scala's new effect library Kyo just uses `map`. See:

https://getkyo.io/#/?id=the-quotpendingquot-type-lt

All pure values are automatically lifted into the Kyo monad, so `map` is effectively `flatMap`.

From the linked docs:

> This unique property removes the need to juggle between map and flatMap. All values are automatically promoted to a Kyo computation with zero pending effects, enabling you to focus on your application logic rather than the intricacies of effect handling.

In the end it makes a lot of sense I think. What you do is manipulating values inside some wrapper. Whether this wrapper is a monad or not should not matter. Just do something with the value(s) inside, and that's mapping.





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: