diff options
author | Fumiaki Kinoshita <fumiexcel@gmail.com> | 2020-07-15 21:12:07 +0900 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-10-14 18:06:12 -0400 |
commit | e60ae8a38394370fd8818ad004a101466fc7d2dc (patch) | |
tree | 6eff280150db65ae373aba5d50f550180b99983b /testsuite/tests/simplCore | |
parent | bf2411a3c198cb2df93a9e0aa0c3b8297f47058d (diff) | |
download | haskell-e60ae8a38394370fd8818ad004a101466fc7d2dc.tar.gz |
Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings
-------------------------
Metric Decrease:
T12425
Metric Increase:
T17516
-------------------------
Diffstat (limited to 'testsuite/tests/simplCore')
6 files changed, 9 insertions, 14 deletions
diff --git a/testsuite/tests/simplCore/prog002/Simpl009Help.hs b/testsuite/tests/simplCore/prog002/Simpl009Help.hs index b64639ec8a..b1e2a080e2 100644 --- a/testsuite/tests/simplCore/prog002/Simpl009Help.hs +++ b/testsuite/tests/simplCore/prog002/Simpl009Help.hs @@ -3,7 +3,7 @@ -- Helper for simpl009.hs (see comments there) module Simpl009Help where - + import Control.Applicative (Applicative(..), Alternative(empty, (<|>))) import Control.Monad @@ -19,12 +19,12 @@ instance Functor (Parser s) where fmap = liftM instance Applicative (Parser s) where - pure = return + pure a = Parser (\fut -> fut a) (<*>) = ap instance Monad (Parser s) where - return a = Parser (\fut -> fut a) - + + Parser f >>= k = Parser (\fut -> f (\a -> let Parser g = k a in g fut)) diff --git a/testsuite/tests/simplCore/should_compile/EvalTest.hs b/testsuite/tests/simplCore/should_compile/EvalTest.hs index dbaba0515d..2795c0421e 100644 --- a/testsuite/tests/simplCore/should_compile/EvalTest.hs +++ b/testsuite/tests/simplCore/should_compile/EvalTest.hs @@ -20,11 +20,10 @@ instance Functor Eval where fmap = liftM instance Applicative Eval where - pure = return + pure = Done (<*>) = ap instance Monad Eval where - return x = Done x Done x >>= k = k x -- Note: pattern 'Done x' makes '>>=' strict rpar :: a -> Eval a diff --git a/testsuite/tests/simplCore/should_compile/T10176.hs b/testsuite/tests/simplCore/should_compile/T10176.hs index e91ccda4e9..c4d738db09 100644 --- a/testsuite/tests/simplCore/should_compile/T10176.hs +++ b/testsuite/tests/simplCore/should_compile/T10176.hs @@ -13,11 +13,10 @@ instance Functor (ReaderT r) where instance Applicative (ReaderT r) where pure = liftReaderT . pure f <*> v = undefined + m *> k = ReaderT $ \r -> do runReaderT m r; runReaderT k r instance Monad (ReaderT r) where - return = liftReaderT . return m >>= k = undefined - m >> k = ReaderT $ \r -> do runReaderT m r; runReaderT k r liftReaderT :: IO a -> ReaderT r a liftReaderT m = ReaderT (const m) diff --git a/testsuite/tests/simplCore/should_compile/T3831.hs b/testsuite/tests/simplCore/should_compile/T3831.hs index 554e786cf2..22689002e5 100644 --- a/testsuite/tests/simplCore/should_compile/T3831.hs +++ b/testsuite/tests/simplCore/should_compile/T3831.hs @@ -1,7 +1,7 @@ {-# OPTIONS_GHC -fno-warn-redundant-constraints #-} {-# LANGUAGE ScopedTypeVariables, FlexibleInstances #-} --- This test has a deep nest of join points, which led to +-- This test has a deep nest of join points, which led to -- an exponential blow-up in GHC.Core.Opt.SpecConstr module T3831(setAttributes) where @@ -24,11 +24,10 @@ instance Functor Capability where fmap = liftM instance Applicative Capability where - pure = return + pure = Capability . const . return . Just (<*>) = ap instance Monad Capability where - return = Capability . const . return . Just Capability f >>= g = Capability $ \t -> do mx <- f t case mx of diff --git a/testsuite/tests/simplCore/should_compile/T4203.hs b/testsuite/tests/simplCore/should_compile/T4203.hs index 3bf9259544..62e1957529 100644 --- a/testsuite/tests/simplCore/should_compile/T4203.hs +++ b/testsuite/tests/simplCore/should_compile/T4203.hs @@ -32,11 +32,10 @@ instance Functor Gen where fmap = liftM instance Applicative Gen where - pure = return + pure = Gen (<*>) = ap instance Monad Gen where - return a = Gen a Gen m >>= k = Gen (let Gen m' = k m in m') class Arbitrary a where diff --git a/testsuite/tests/simplCore/should_compile/T8331.hs b/testsuite/tests/simplCore/should_compile/T8331.hs index a7dc318826..3ad183e293 100644 --- a/testsuite/tests/simplCore/should_compile/T8331.hs +++ b/testsuite/tests/simplCore/should_compile/T8331.hs @@ -19,7 +19,6 @@ instance (Functor m) => Functor (ReaderT r m) where fmap f = mapReaderT (fmap f) instance (Monad m) => Monad (ReaderT r m) where - return x = ReaderT (\_ -> return x) m >>= k = ReaderT $ \ r -> do a <- runReaderT m r runReaderT (k a) r |