| ... | ... | @@ -39,18 +39,35 @@ The [Libraries/Proposals/MonadFail](libraries/proposals/monad-fail) proposal is |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Please see [Libraries/Proposals/MonadFail](libraries/proposals/monad-fail) for details on that particular proposal; the example here might not be up-to-date in case the MonadFail? transition changes.
|
|
|
|
Please see [Libraries/Proposals/MonadFail](libraries/proposals/monad-fail) for details on that particular proposal; the example here might not be up-to-date in case the MonadFail transition changes.
|
|
|
|
|
|
|
|
|
|
|
|
### pre GHC-8.0
|
|
|
|
<table><tr><th>
|
|
|
|
Version
|
|
|
|
|
|
|
|
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
Changes
|
|
|
|
|
|
|
|
|
|
|
|
Backward-compatible code:
|
|
|
|
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
Backwards-Compatible code
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
</th></tr>
|
|
|
|
<tr><th>
|
|
|
|
pre 8.0
|
|
|
|
|
|
|
|
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
–
|
|
|
|
|
|
|
|
|
|
|
|
</th>
|
|
|
|
<th>```
|
|
|
|
instance Monad Foo where
|
|
|
|
...
|
|
|
|
fail = ...
|
| ... | ... | @@ -59,42 +76,38 @@ do Just x <- ... |
|
|
|
return x
|
|
|
|
```
|
|
|
|
|
|
|
|
### GHC-8.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Changes implemented:
|
|
|
|
</th></tr>
|
|
|
|
<tr><th>
|
|
|
|
8.0
|
|
|
|
|
|
|
|
|
|
|
|
- Module `Control.Monad.Fail` with class `MonadFail` and method `fail`, distinct from `Prelude`’s `fail` added.
|
|
|
|
</th>
|
|
|
|
<th>- Module `Control.Monad.Fail` with class `MonadFail` and method `fail`, distinct from `Prelude`’s `fail` added.
|
|
|
|
- Language extension `-XMonadFailDesugaring` to change the desugaring to use that `fail`
|
|
|
|
- (Some warnings, off by default, are added)
|
|
|
|
|
|
|
|
|
|
|
|
Backward-compatible code as above.
|
|
|
|
|
|
|
|
|
|
|
|
### GHC-8.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
No change, backward-compatible code as above.
|
|
|
|
|
|
|
|
|
|
|
|
### GHC-8.4
|
|
|
|
</th>
|
|
|
|
<th></th></tr>
|
|
|
|
<tr><th>
|
|
|
|
8.2
|
|
|
|
|
|
|
|
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
*none*
|
|
|
|
|
|
|
|
Changes implemented:
|
|
|
|
|
|
|
|
</th>
|
|
|
|
<th></th></tr>
|
|
|
|
<tr><th>
|
|
|
|
8.4
|
|
|
|
|
|
|
|
- Warn by default when a `MonadFail` instance is not in scope where do-notation desugars to `fail`.
|
|
|
|
|
|
|
|
</th>
|
|
|
|
<th>- Warn by default when a `MonadFail` instance is not in scope where do-notation desugars to `fail`.
|
|
|
|
|
|
|
|
Backward-compatible code:
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
</th>
|
|
|
|
<th>```
|
|
|
|
import qualified Control.Monad.Fail as Fail
|
|
|
|
|
|
|
|
instance Monad Foo where
|
| ... | ... | @@ -109,25 +122,17 @@ do Just x <- ... |
|
|
|
return x
|
|
|
|
```
|
|
|
|
|
|
|
|
### GHC-8.6
|
|
|
|
|
|
|
|
|
|
|
|
</th></tr>
|
|
|
|
<tr><th>
|
|
|
|
8.6
|
|
|
|
|
|
|
|
Changes implemented:
|
|
|
|
|
|
|
|
|
|
|
|
- `-XMonadFailDesugaring` is the default now
|
|
|
|
</th>
|
|
|
|
<th>- `-XMonadFailDesugaring` is the default now
|
|
|
|
- Explicit definitions of `Monad.fail` cause warnings now.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Backward-compatible code:
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
</th>
|
|
|
|
<th>```
|
|
|
|
{-# LANGUAGE MonadFailDesugaring #-}
|
|
|
|
import qualified Control.Monad.Fail as Fail
|
|
|
|
|
| ... | ... | @@ -139,19 +144,17 @@ do Just x <- ... |
|
|
|
return x
|
|
|
|
```
|
|
|
|
|
|
|
|
### GHC-8.8
|
|
|
|
</th></tr>
|
|
|
|
<tr><th>
|
|
|
|
8.8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Changes implemented:
|
|
|
|
|
|
|
|
|
|
|
|
- `-XMonadFailDesugaring` is unconditionally true
|
|
|
|
</th>
|
|
|
|
<th>- `-XMonadFailDesugaring` is unconditionally true
|
|
|
|
- `Monad.fail is removed`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Backward-compatible code: Same as above.
|
|
|
|
</th>
|
|
|
|
<th></th></tr></table>
|
|
|
|
|
|
|
|
|
|
|
|
## History
|
| ... | ... | |