Skip to content

WIP: Add a new default language extension FallibleDo

cgibbard requested to merge obsidiansystems/ghc:cg-ext-disable-MonadFail into master

FallibleDo is a new default language extension which reflects the use of fail from the MonadFail type class when desugaring pattern matches that may fail to match.

For cases where one has no need of MonadFail's ability to override the behaviour of these cases, NoFallibleDo effectively causes fail in do-syntax desugaring to be replaced by error, and adds corresponding warnings when -Wincomplete-uni-patterns is turned on.

This is intended to help in some of the situations like where do-syntax desugaring breaks down a bit in the case of pattern synonyms or GADTs, resulting in additional MonadFail constraints even when a pattern has a corresponding COMPLETE pragma for example, or when it's the only pattern that has the appropriate type index.

It's certainly not entirely ideal, but adding an optional way to turn off MonadFail usage altogether was at least simpler to design and implement than many alternative approaches. We may want to continue looking at improving the situation in other ways as well, but for some cases at least, this should help out.

We still need to add support to Cabal, as well as to add some test cases to this PR, but it mostly appears to be working.

Edited by John Ericson

Merge request reports