diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2016-01-01 01:45:08 +0100 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2016-01-01 01:55:16 +0100 |
commit | dafeb51f266793a67e8ae18ae39a2e2e87943824 (patch) | |
tree | f1ef3abd7fc655e6b8896a6841f0efd9a39a39fe /compiler/simplCore/CoreMonad.hs | |
parent | 8afeaad919dc67643b4eff14efafb48b59039b2b (diff) | |
download | haskell-dafeb51f266793a67e8ae18ae39a2e2e87943824.tar.gz |
Canonicalise `MonadPlus` instances
This refactoring exploits the fact that since AMP, in most cases,
`instance MonadPlus` can be automatically derived from the respective
`Alternative` instance. This is because `MonadPlus`'s default method
implementations are fully defined in terms of `Alternative(empty, (<>))`.
Diffstat (limited to 'compiler/simplCore/CoreMonad.hs')
-rw-r--r-- | compiler/simplCore/CoreMonad.hs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/compiler/simplCore/CoreMonad.hs b/compiler/simplCore/CoreMonad.hs index 4958474a9d..9f80a17869 100644 --- a/compiler/simplCore/CoreMonad.hs +++ b/compiler/simplCore/CoreMonad.hs @@ -4,7 +4,7 @@ \section[CoreMonad]{The core pipeline monad} -} -{-# LANGUAGE CPP, UndecidableInstances #-} +{-# LANGUAGE CPP #-} module CoreMonad ( -- * Configuration of the core-to-core passes @@ -570,15 +570,11 @@ instance Applicative CoreM where (<*>) = ap m *> k = m >>= \_ -> k -instance MonadPlus IO => Alternative CoreM where - empty = mzero - (<|>) = mplus +instance Alternative CoreM where + empty = CoreM (const Control.Applicative.empty) + m <|> n = CoreM (\rs -> unCoreM m rs <|> unCoreM n rs) --- For use if the user has imported Control.Monad.Error from MTL --- Requires UndecidableInstances -instance MonadPlus IO => MonadPlus CoreM where - mzero = CoreM (const mzero) - m `mplus` n = CoreM (\rs -> unCoreM m rs `mplus` unCoreM n rs) +instance MonadPlus CoreM instance MonadUnique CoreM where getUniqueSupplyM = do |