... | ... | @@ -173,10 +173,10 @@ Both of those tell us the "real" desugaring as just another pattern we could rec |
|
|
```
|
|
|
importControl.Monad-- Control.Monad.Fail import will become redundant in GHC 8.8+importqualifiedControl.Monad.Failas Fail
|
|
|
|
|
|
instanceMonadFoowhere(>>=)=<...bind impl...>-- NB: `return` defaults to `pure` since GHC 7.10-- Monad(fail) will be removed in GHC 8.8+
|
|
|
instanceMonadFoowhere(>>=)=<...bind impl...>-- NB: `return` defaults to `pure` since GHC 7.10-- Monad(fail) will be removed in GHC 8.8+; -- GHC may or may not ignore a definition in terms of MonadFail(fail) (decision pending)
|
|
|
fail =Fail.fail
|
|
|
|
|
|
instanceMonadFailFoowhere
|
|
|
instanceFail.MonadFailFoowhere
|
|
|
fail =<...fail implementation...>
|
|
|
```
|
|
|
1. Change your pattern to be irrefutable
|
... | ... | @@ -184,16 +184,16 @@ Both of those tell us the "real" desugaring as just another pattern we could rec |
|
|
|
|
|
```
|
|
|
doLeft e <- foobar
|
|
|
stuff
|
|
|
stuff
|
|
|
```
|
|
|
|
|
|
becomes
|
|
|
|
|
|
```
|
|
|
do x <- foobar
|
|
|
e <-case x ofLeft e' -> e'
|
|
|
e <-case x ofLeft e' -> e'
|
|
|
Right r ->error"Pattern match failed"-- Boooo
|
|
|
stuff
|
|
|
stuff
|
|
|
```
|
|
|
|
|
|
The point is you'll have to do your dirty laundry yourself now if you have a value that *you* know will always match, and if you don't handle the other patterns you'll get incompleteness warnings, and the compiler won't silently eat those for you.
|
... | ... | |