6 ms·
Could you elaborate on that? What does 'flatMappable' mean in this context?
by aadhavans 1y ago
Could you elaborate on that? What does 'flatMappable' mean in this context?
- IshKebab 1y agoThis is a good explanation: https://users.scala-lang.org/t/what-is-a-monad-in-scala/4169 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.
- skybrian 1y agoThat’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.
- still_grokking 1y agoScala's new effect library Kyo just uses `map`. See: https://getkyo.io/#/?id=the-quotpendingquot-type-lt 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.
- gr4vityWall 1y agosomething that you can call flatMap() on. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...