Timeline for How Does The Maybe Monad Relate To The Option Type?
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 7, 2016 at 22:44 | comment | added | Jack | F#'s Option's map and bind functions behave identically to Haskell's Maybe's fmap and bind functions. They are both monads and have equivalent monadic behavior. Haskell just has a Monad typeclass that lets you manipulate monads, while in F# they're more like an abstract "design pattern". | |
| Jun 7, 2016 at 21:15 | comment | added | sara | in short: I don't at all agree that they're not equivalent. language constructs like type classes or polymorphism doesn't change a types fundamental mathematical properties and structure. | |
| Jun 7, 2016 at 21:12 | comment | added | sara | I think it's worth noting that technically speaking, a monad isn't so much a type as it is a mathematical structure. The option type has a valid type contructor (Some(val : a) : a option) and it'd be trivial to write a bind implementation for it (if it doesn't already exist in the option module in F# which wouldn't surprise me). The Monad typeclass in haskell isn't what magically turns something into a monad, it's just a syntactic way of telling the compiler about the interface of the Maybe (for instance) type. This allows for polymorphism over monads, it doesn't allow monads per se. | |
| Jun 22, 2012 at 14:23 | comment | added | tdammers | @OnorioCatenacci: Ah, OK. I haven't had an awful lot of F# exposure, so excuse me. Anyway, in Haskell, monads are types, more specifically, types of the Monad typeclass. Maybe is a plain old data type, but it also happens to implement Monad to provide this 'special' behavior. | |
| Jun 22, 2012 at 13:57 | vote | accept | Onorio Catenacci | ||
| Jun 22, 2012 at 13:56 | comment | added | Onorio Catenacci | BTW--there is a monad type of concept in F#; it's called a computation expression. | |
| Jun 22, 2012 at 13:55 | comment | added | Onorio Catenacci | Thanks for the lucid explanation. Frankly I always considered they weren't the same (one's a type the other's a monad) but I wasn't altogether clear on how one related to the other. | |
| Jun 22, 2012 at 13:46 | history | answered | tdammers | CC BY-SA 3.0 |