From 0d09d4c7997bd34715e2fe4817778bdcb13b22ca Mon Sep 17 00:00:00 2001 From: Jack Kelly Date: Mon, 6 May 2024 15:25:48 +1000 Subject: [PATCH] Remove `instance PluckError e (Except e) m` The presence of this instance causes overlapping instance errors when trying to hoist `ExceptT e m a` values for unknown `m`. `Except e` is an alias for `ExceptT e Identity`, is isomorphic to `Either e`, and I don't think I've ever seen it in production code. --- changelog.md | 3 +++ src/Control/Monad/Error/Hoist.hs | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 15967af..25284de 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,9 @@ * Replaced the `HoistError` typeclass, which is about monads, with a simpler `PluckError` typeclass that is about extracting errors from values. +* Removed the instance for `Except e`, as it triggers overlapping + instance errors when attempting to hoist `ExceptT e m` for unknown + monads `m`. * Introduced a parallel `Control.Monad.Fail.Hoist` module, for hoisting error messages into `MonadFail`. diff --git a/src/Control/Monad/Error/Hoist.hs b/src/Control/Monad/Error/Hoist.hs index 3ab7e5a..2363103 100644 --- a/src/Control/Monad/Error/Hoist.hs +++ b/src/Control/Monad/Error/Hoist.hs @@ -194,7 +194,3 @@ instance Applicative m => PluckError e (Either e) m where instance Monad m => PluckError e (ExceptT e m) m where pluckError = runExceptT foldError f g = either f g <=< runExceptT - -instance Applicative m => PluckError e (Except e) m where - pluckError = pure . runExcept - foldError f g = either f g . runExcept