| ... | @@ -28,48 +28,61 @@ We picked three releases as a good compromise between the wish to rapidly implem |
... | @@ -28,48 +28,61 @@ We picked three releases as a good compromise between the wish to rapidly implem |
|
|
The [Libraries/Proposals/MonadFail](libraries/proposals/monad-fail) proposal is an example of a transition that adheres to this policy, and serves here as an example of a few of the mechanisms that can be used to achieve this. This is not the only possible way to implement it, nor is the given code the only way to write it in light of the changes (e.g. in case a libraries author actually prefers CPP).
|
|
The [Libraries/Proposals/MonadFail](libraries/proposals/monad-fail) proposal is an example of a transition that adheres to this policy, and serves here as an example of a few of the mechanisms that can be used to achieve this. This is not the only possible way to implement it, nor is the given code the only way to write it in light of the changes (e.g. in case a libraries author actually prefers CPP).
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
</th>
|
|
|
Backward-compatible code:
|
|
<th>
|
|
|
|
Backwards-Compatible code
|
|
|
|
|
|
|
|
```
|
|
</th></tr>
|
|
|
|
<tr><th>
|
|
|
|
pre 8.0
|
|
|
|
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
–
|
|
|
|
|
|
|
|
</th>
|
|
|
|
<th>```
|
|
|
instanceMonadFoowhere...
|
|
instanceMonadFoowhere...
|
|
|
fail =...doJust x <-...
|
|
fail =...doJust x <-...
|
|
|
return x
|
|
return x
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### GHC-8.0
|
|
</th></tr>
|
|
|
|
<tr><th>
|
|
|
|
8.0
|
|
|
|
|
|
|
|
|
|
</th>
|
|
|
Changes implemented:
|
|
<th>- Module `Control.Monad.Fail` with class `MonadFail` and method `fail`, distinct from `Prelude`’s `fail` added.
|
|
|
|
|
|
|
|
- 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`
|
|
- Language extension `-XMonadFailDesugaring` to change the desugaring to use that `fail`
|
|
|
- (Some warnings, off by default, are added)
|
|
- (Some warnings, off by default, are added)
|
|
|
|
|
|
|
|
|
</th>
|
|
|
|
<th></th></tr>
|
|
|
|
<tr><th>
|
|
|
|
8.2
|
|
|
|
|
|
|
|
Backward-compatible code as above.
|
|
</th>
|
|
|
|
|
<th>*none*
|
|
|
### GHC-8.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
No change, backward-compatible code as above.
|
|
|
|
|
|
|
|
|
|
### GHC-8.4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Changes implemented:
|
|
|
|
|
|
|
|
|
|
- Warn by default when a `MonadFail` instance is not in scope where do-notation desugars to `fail`.
|
|
</th>
|
|
|
|
<th></th></tr>
|
|
|
|
<tr><th>
|
|
|
|
8.4
|
|
|
|
|
|
|
|
|
</th>
|
|
|
|
<th>- Warn by default when a `MonadFail` instance is not in scope where do-notation desugars to `fail`.
|
|
|
|
|
|
|
|
Backward-compatible code:
|
|
</th>
|
|
|
|
|
<th>```
|
|
|
```
|
|
|
|
|
importqualifiedControl.Monad.Failas Fail
|
|
importqualifiedControl.Monad.Failas Fail
|
|
|
|
|
|
|
|
instanceMonadFoowhere...
|
|
instanceMonadFoowhere...
|
| ... | @@ -80,18 +93,16 @@ instanceFail.MonadFailFoowhere... |
... | @@ -80,18 +93,16 @@ instanceFail.MonadFailFoowhere... |
|
|
return x
|
|
return x
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### GHC-8.6
|
|
</th></tr>
|
|
|
|
|
<tr><th>
|
|
|
|
8.6
|
|
|
|
|
|
|
|
Changes implemented:
|
|
</th>
|
|
|
|
|
<th>- `-XMonadFailDesugaring` is the default now
|
|
|
- `-XMonadFailDesugaring` is the default now
|
|
|
|
|
- Explicit definitions of `Monad.fail` cause warnings now.
|
|
- Explicit definitions of `Monad.fail` cause warnings now.
|
|
|
|
|
|
|
|
|
|
</th>
|
|
|
Backward-compatible code:
|
|
<th>```
|
|
|
|
|
|
|
|
```
|
|
|
|
|
{-# LANGUAGE MonadFailDesugaring #-}importqualifiedControl.Monad.Failas Fail
|
|
{-# LANGUAGE MonadFailDesugaring #-}importqualifiedControl.Monad.Failas Fail
|
|
|
|
|
|
|
|
instanceFail.MonadFailFoowhere...
|
|
instanceFail.MonadFailFoowhere...
|
| ... | @@ -99,17 +110,16 @@ instanceFail.MonadFailFoowhere... |
... | @@ -99,17 +110,16 @@ instanceFail.MonadFailFoowhere... |
|
|
return x
|
|
return x
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### GHC-8.8
|
|
</th></tr>
|
|
|
|
|
<tr><th>
|
|
|
|
8.8
|
|
|
|
|
|
|
|
Changes implemented:
|
|
</th>
|
|
|
|
|
<th>- `-XMonadFailDesugaring` is unconditionally true
|
|
|
- `-XMonadFailDesugaring` is unconditionally true
|
|
|
|
|
- `Monad.fail is removed`
|
|
- `Monad.fail is removed`
|
|
|
|
|
|
|
|
|
|
</th>
|
|
|
|
|
<th></th></tr></table>
|
|
|
Backward-compatible code: Same as above.
|
|
|
|
|
|
|
|
|
|
## History
|
|
## History
|
|
|
|
|
|
| ... | | ... | |