Skip to content

Commit 25a3875

Browse files
committed
Type.Infer: instance MonadTrans Solver: fx MonadPlus code
With the help of `turion` in #851 found that: ```haskell throwError err = Solver $ lift (modify (err :)) *> mzero == mzero ``` By a MonadPlus law is ```haskell throwError _err = Solver mzero ``` Which is hardly what the code was about, writer probably wanted to use Alternative, where the law does not applies.
1 parent 4796681 commit 25a3875

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Nix/Type/Infer.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module Nix.Type.Infer
2828
where
2929

3030
import Control.Applicative
31+
import qualified Control.Applicative as Applicative
3132
import Control.Arrow
3233
import Control.Monad.Catch
3334
import Control.Monad.Except
@@ -669,7 +670,7 @@ instance MonadTrans Solver where
669670
lift = Solver . lift . lift
670671

671672
instance Monad m => MonadError TypeError (Solver m) where
672-
throwError err = Solver $ lift (modify (err :)) *> mzero
673+
throwError err = Solver $ lift (modify (err :)) *> Applicative.empty
673674
catchError _ _ = error "This is never used"
674675

675676
runSolver :: Monad m => Solver m a -> m (Either [TypeError] [a])

0 commit comments

Comments
 (0)