|
|
|
|
|
by leifmetcalf
508 days ago
|
|
Elixir doesn’t even need a special syntax — it gets Haskell’s LambdaCase as a natural consequence of case being just another function, and the pipe operator always chaining by the first argument. Haskell’s >>= is doing something slightly different. ‘getThing >>= \case…’ means roughly ‘perform the action getThing, then match the result and perform the matched branch’ Whereas ‘getThing |> \case…’ means ‘pattern match on the action getThing, and return the matched action (without performing it). The >>= operator can also be used for anything satisfying the Monad laws, e.g. your actions can be non-deterministic. |
|