Skip to content

Commit 9d519d1

Browse files
authored
Remove noncanonical definitions (#96)
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
1 parent 112523c commit 9d519d1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/System/IO/Streams/Internal.hs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,9 @@ generatorBind (Generator m) f = Generator (m >>= either step value)
596596

597597
------------------------------------------------------------------------------
598598
instance Monad (Generator r) where
599-
return = Generator . return . Right
599+
#if !MIN_VERSION_base(4,8,0)
600+
return = pure
601+
#endif
600602
(>>=) = generatorBind
601603

602604

@@ -656,7 +658,9 @@ newtype Consumer c a = Consumer {
656658

657659
------------------------------------------------------------------------------
658660
instance Monad (Consumer c) where
659-
return = Consumer . return . Right
661+
#if !MIN_VERSION_base(4,8,0)
662+
return = pure
663+
#endif
660664

661665
(Consumer m) >>= f = Consumer $ m >>= either step value
662666
where
@@ -679,7 +683,7 @@ instance Functor (Consumer r) where
679683

680684
------------------------------------------------------------------------------
681685
instance Applicative (Consumer r) where
682-
pure = return
686+
pure = Consumer . pure . Right
683687

684688
m <*> n = do
685689
f <- m

0 commit comments

Comments
 (0)