From 625aa5eb9b6a2ef14a9b287d69b4c8c4c8d8a955 Mon Sep 17 00:00:00 2001 From: Ryan Hendrickson Date: Thu, 20 Mar 2025 21:49:31 -0400 Subject: [PATCH] Remove noncanonical definitions This appeases the -Wnoncanonical-monad-instances warning. This warning exists because a future GHC release may treat noncanonical definitions as errors. See also: https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/monad-of-no-return --- src/System/IO/Streams/Internal.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/System/IO/Streams/Internal.hs b/src/System/IO/Streams/Internal.hs index a568a9a..5630a07 100644 --- a/src/System/IO/Streams/Internal.hs +++ b/src/System/IO/Streams/Internal.hs @@ -596,7 +596,9 @@ generatorBind (Generator m) f = Generator (m >>= either step value) ------------------------------------------------------------------------------ instance Monad (Generator r) where - return = Generator . return . Right +#if !MIN_VERSION_base(4,8,0) + return = pure +#endif (>>=) = generatorBind @@ -656,7 +658,9 @@ newtype Consumer c a = Consumer { ------------------------------------------------------------------------------ instance Monad (Consumer c) where - return = Consumer . return . Right +#if !MIN_VERSION_base(4,8,0) + return = pure +#endif (Consumer m) >>= f = Consumer $ m >>= either step value where @@ -679,7 +683,7 @@ instance Functor (Consumer r) where ------------------------------------------------------------------------------ instance Applicative (Consumer r) where - pure = return + pure = Consumer . pure . Right m <*> n = do f <- m