diff options
| author | Seraphime Kirkovski <kirkseraph@gmail.com> | 2016-06-06 12:29:38 +0200 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2016-06-06 15:07:18 +0200 |
| commit | a90085bd45239fffd65c01c24752a9bbcef346f1 (patch) | |
| tree | 41a85ba36720d8fba0a3296ea7a844dd9fc0042a /libraries/base/Control/Monad | |
| parent | 48e9a1f5521fa3185510d144dd28a87e452ce134 (diff) | |
| download | haskell-a90085bd45239fffd65c01c24752a9bbcef346f1.tar.gz | |
Add @since annotations to base instances
Add @since annotations to instances in `base`.
Test Plan:
* ./validate # some commets shouldn't break the build
* review the annotations for absurdities.
Reviewers: ekmett, goldfire, RyanGlScott, austin, hvr, bgamari
Reviewed By: RyanGlScott, hvr, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2277
GHC Trac Issues: #11767
Diffstat (limited to 'libraries/base/Control/Monad')
| -rw-r--r-- | libraries/base/Control/Monad/Fail.hs | 3 | ||||
| -rw-r--r-- | libraries/base/Control/Monad/Fix.hs | 16 | ||||
| -rw-r--r-- | libraries/base/Control/Monad/IO/Class.hs | 1 | ||||
| -rw-r--r-- | libraries/base/Control/Monad/ST/Lazy/Imp.hs | 4 | ||||
| -rw-r--r-- | libraries/base/Control/Monad/Zip.hs | 14 |
5 files changed, 38 insertions, 0 deletions
diff --git a/libraries/base/Control/Monad/Fail.hs b/libraries/base/Control/Monad/Fail.hs index 9c5afbe57a..91ef3ed349 100644 --- a/libraries/base/Control/Monad/Fail.hs +++ b/libraries/base/Control/Monad/Fail.hs @@ -67,12 +67,15 @@ class Monad m => MonadFail m where fail :: String -> m a +-- | @since 4.9.0.0 instance MonadFail Maybe where fail _ = Nothing +-- | @since 4.9.0.0 instance MonadFail [] where {-# INLINE fail #-} fail _ = [] +-- | @since 4.9.0.0 instance MonadFail IO where fail = failIO diff --git a/libraries/base/Control/Monad/Fix.hs b/libraries/base/Control/Monad/Fix.hs index 4862770f26..c8a9ddab58 100644 --- a/libraries/base/Control/Monad/Fix.hs +++ b/libraries/base/Control/Monad/Fix.hs @@ -62,60 +62,76 @@ class (Monad m) => MonadFix m where -- Instances of MonadFix for Prelude monads +-- | @since 2.01 instance MonadFix Maybe where mfix f = let a = f (unJust a) in a where unJust (Just x) = x unJust Nothing = errorWithoutStackTrace "mfix Maybe: Nothing" +-- | @since 2.01 instance MonadFix [] where mfix f = case fix (f . head) of [] -> [] (x:_) -> x : mfix (tail . f) +-- | @since 2.01 instance MonadFix IO where mfix = fixIO +-- | @since 2.01 instance MonadFix ((->) r) where mfix f = \ r -> let a = f a r in a +-- | @since 4.3.0.0 instance MonadFix (Either e) where mfix f = let a = f (unRight a) in a where unRight (Right x) = x unRight (Left _) = errorWithoutStackTrace "mfix Either: Left" +-- | @since 2.01 instance MonadFix (ST s) where mfix = fixST -- Instances of Data.Monoid wrappers +-- | @since 4.8.0.0 instance MonadFix Dual where mfix f = Dual (fix (getDual . f)) +-- | @since 4.8.0.0 instance MonadFix Sum where mfix f = Sum (fix (getSum . f)) +-- | @since 4.8.0.0 instance MonadFix Product where mfix f = Product (fix (getProduct . f)) +-- | @since 4.8.0.0 instance MonadFix First where mfix f = First (mfix (getFirst . f)) +-- | @since 4.8.0.0 instance MonadFix Last where mfix f = Last (mfix (getLast . f)) +-- | @since 4.8.0.0 instance MonadFix f => MonadFix (Alt f) where mfix f = Alt (mfix (getAlt . f)) -- Instances for GHC.Generics +-- | @since 4.9.0.0 instance MonadFix Par1 where mfix f = Par1 (fix (unPar1 . f)) +-- | @since 4.9.0.0 instance MonadFix f => MonadFix (Rec1 f) where mfix f = Rec1 (mfix (unRec1 . f)) +-- | @since 4.9.0.0 instance MonadFix f => MonadFix (M1 i c f) where mfix f = M1 (mfix (unM1. f)) +-- | @since 4.9.0.0 instance (MonadFix f, MonadFix g) => MonadFix (f :*: g) where mfix f = (mfix (fstP . f)) :*: (mfix (sndP . f)) where diff --git a/libraries/base/Control/Monad/IO/Class.hs b/libraries/base/Control/Monad/IO/Class.hs index b2c419c3a7..76806e132d 100644 --- a/libraries/base/Control/Monad/IO/Class.hs +++ b/libraries/base/Control/Monad/IO/Class.hs @@ -32,5 +32,6 @@ class (Monad m) => MonadIO m where -- | Lift a computation from the 'IO' monad. liftIO :: IO a -> m a +-- | @since 4.9.0.0 instance MonadIO IO where liftIO = id diff --git a/libraries/base/Control/Monad/ST/Lazy/Imp.hs b/libraries/base/Control/Monad/ST/Lazy/Imp.hs index 51b1d86e09..45d2219dce 100644 --- a/libraries/base/Control/Monad/ST/Lazy/Imp.hs +++ b/libraries/base/Control/Monad/ST/Lazy/Imp.hs @@ -62,6 +62,7 @@ import GHC.Base newtype ST s a = ST (State s -> (a, State s)) data State s = S# (State# s) +-- | @since 2.01 instance Functor (ST s) where fmap f m = ST $ \ s -> let @@ -70,10 +71,12 @@ instance Functor (ST s) where in (f r,new_s) +-- | @since 2.01 instance Applicative (ST s) where pure a = ST $ \ s -> (a,s) (<*>) = ap +-- | @since 2.01 instance Monad (ST s) where fail s = errorWithoutStackTrace s @@ -104,6 +107,7 @@ fixST m = ST (\ s -> in (r,s')) +-- | @since 2.01 instance MonadFix (ST s) where mfix = fixST diff --git a/libraries/base/Control/Monad/Zip.hs b/libraries/base/Control/Monad/Zip.hs index fa44438176..f102ff06ad 100644 --- a/libraries/base/Control/Monad/Zip.hs +++ b/libraries/base/Control/Monad/Zip.hs @@ -52,48 +52,62 @@ class Monad m => MonadZip m where -- you can implement it more efficiently than the -- above default code. See Trac #4370 comment by giorgidze +-- | @since 4.3.1.0 instance MonadZip [] where mzip = zip mzipWith = zipWith munzip = unzip +-- | @since 4.8.0.0 instance MonadZip Dual where -- Cannot use coerce, it's unsafe mzipWith = liftM2 +-- | @since 4.8.0.0 instance MonadZip Sum where mzipWith = liftM2 +-- | @since 4.8.0.0 instance MonadZip Product where mzipWith = liftM2 +-- | @since 4.8.0.0 instance MonadZip Maybe where mzipWith = liftM2 +-- | @since 4.8.0.0 instance MonadZip First where mzipWith = liftM2 +-- | @since 4.8.0.0 instance MonadZip Last where mzipWith = liftM2 +-- | @since 4.8.0.0 instance MonadZip f => MonadZip (Alt f) where mzipWith f (Alt ma) (Alt mb) = Alt (mzipWith f ma mb) +-- | @since 4.9.0.0 instance MonadZip Proxy where mzipWith _ _ _ = Proxy -- Instances for GHC.Generics +-- | @since 4.9.0.0 instance MonadZip U1 where mzipWith _ _ _ = U1 +-- | @since 4.9.0.0 instance MonadZip Par1 where mzipWith = liftM2 +-- | @since 4.9.0.0 instance MonadZip f => MonadZip (Rec1 f) where mzipWith f (Rec1 fa) (Rec1 fb) = Rec1 (mzipWith f fa fb) +-- | @since 4.9.0.0 instance MonadZip f => MonadZip (M1 i c f) where mzipWith f (M1 fa) (M1 fb) = M1 (mzipWith f fa fb) +-- | @since 4.9.0.0 instance (MonadZip f, MonadZip g) => MonadZip (f :*: g) where mzipWith f (x1 :*: y1) (x2 :*: y2) = mzipWith f x1 x2 :*: mzipWith f y1 y2 |
