[Git][ghc/ghc][master] base: Update doctests outputs

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Wed May 22 04:34:37 UTC 2024



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
3bad5d55 by Hécate Moonlight at 2024-05-22T00:33:40-04:00
base: Update doctests outputs

ghc-internal: Update doctests outputs

- - - - -


18 changed files:

- libraries/base/src/Data/Bifoldable.hs
- libraries/base/src/Data/Bifunctor.hs
- libraries/base/src/Data/Bitraversable.hs
- libraries/base/src/Data/Complex.hs
- libraries/base/src/Data/Fixed.hs
- libraries/base/src/Data/Foldable.hs
- libraries/base/src/Data/Foldable1.hs
- libraries/base/src/Data/Functor.hs
- libraries/base/src/Data/Functor/Compose.hs
- libraries/base/src/Data/Functor/Product.hs
- libraries/base/src/Data/Functor/Sum.hs
- libraries/base/src/Data/List/NonEmpty.hs
- libraries/base/src/Data/Monoid.hs
- libraries/base/src/Data/Semigroup.hs
- libraries/base/src/Data/Traversable.hs
- libraries/base/src/System/IO.hs
- libraries/ghc-internal/src/GHC/Internal/Base.hs
- libraries/ghc-internal/src/GHC/Internal/Data/Monoid.hs


Changes:

=====================================
libraries/base/src/Data/Bifoldable.hs
=====================================
@@ -238,8 +238,8 @@ class Bifoldable p where
 --
 -- >>> bifoldr (flip const) (:) [] (undefined :: (Int, Word)) `seq` ()
 -- ()
--- >>> foldr (:) [] (undefined :: (Int, Word)) `seq` ()
--- *** Exception: Prelude.undefined
+-- >>> foldr (:) [] (errorWithoutStackTrace "error!" :: (Int, Word)) `seq` ()
+-- *** Exception: error!
 --
 -- @since 4.10.0.0
 instance Bifoldable (,) where


=====================================
libraries/base/src/Data/Bifunctor.hs
=====================================
@@ -140,8 +140,8 @@ class (forall a. Functor (p a)) => Bifunctor p where
 -- ()
 -- >>> second id (undefined :: (Int, Word)) `seq` ()
 -- ()
--- >>> id (undefined :: (Int, Word)) `seq` ()
--- *** Exception: Prelude.undefined
+-- >>> id (errorWithoutStackTrace "error!" :: (Int, Word)) `seq` ()
+-- *** Exception: error!
 --
 -- @since 4.8.0.0
 instance Bifunctor (,) where


=====================================
libraries/base/src/Data/Bitraversable.hs
=====================================
@@ -179,8 +179,8 @@ bisequence = bitraverse id id
 --
 -- >>> (bitraverse pure pure undefined :: IO (Int, Word)) `seq` ()
 -- ()
--- >>> (traverse pure undefined :: IO (Int, Word)) `seq` ()
--- *** Exception: Prelude.undefined
+-- >>> (traverse pure (errorWithoutStackTrace "error!") :: IO (Int, Word)) `seq` ()
+-- *** Exception: error!
 --
 -- @since 4.10.0.0
 instance Bitraversable (,) where


=====================================
libraries/base/src/Data/Complex.hs
=====================================
@@ -47,6 +47,9 @@ import Control.Monad.Zip (MonadZip(..))
 
 infix  6  :+
 
+-- $setup
+-- >>> import Prelude
+
 -- -----------------------------------------------------------------------------
 -- The Complex type
 
@@ -85,6 +88,7 @@ infix  6  :+
 -- >>> mapM print (1 :+ 2)
 -- 1
 -- 2
+-- () :+ ()
 data Complex a
   = !a :+ !a    -- ^ forms a complex number from its real and imaginary
                 -- rectangular components.


=====================================
libraries/base/src/Data/Fixed.hs
=====================================
@@ -93,6 +93,9 @@ import GHC.Internal.Text.Read.Lex
 import Data.Typeable
 import Prelude
 
+-- $setup
+-- >>> import Prelude
+
 default () -- avoid any defaulting shenanigans
 
 -- | Generalisation of 'div' to any instance of 'Real'


=====================================
libraries/base/src/Data/Foldable.hs
=====================================
@@ -98,6 +98,10 @@ module Data.Foldable (
 
 import GHC.Internal.Data.Foldable
 
+-- $setup
+-- >>> import Prelude
+-- >>> import qualified Data.List as List
+
 -- $overview
 --
 -- #overview#
@@ -141,7 +145,7 @@ import GHC.Internal.Data.Foldable
 --
 -- >>> foldl' (+) 0 [1..100]
 -- 5050
--- >>> foldr (&&) True (repeat False)
+-- >>> foldr (&&) True (List.repeat False)
 -- False
 --
 -- The first argument of both is an explicit /operator/ that merges the
@@ -405,7 +409,7 @@ import GHC.Internal.Data.Foldable
 -- segment.
 --
 -- >>> myconcat = foldr (\x z -> foldr (:) z x) []
--- >>> take 15 $ myconcat $ map (\i -> [0..i]) [0..]
+-- >>> List.take 15 $ myconcat $ List.map (\i -> [0..i]) [0..]
 -- [0,0,1,0,1,2,0,1,2,3,0,1,2,3,4]
 --
 -- Of course in this case another way to achieve the same result is via a
@@ -536,13 +540,13 @@ import GHC.Internal.Data.Foldable
 --     then the evaluated effects will be from an initial portion of the
 --     element sequence.
 --
---     >>> :set -XBangPatterns
---     >>> import Control.Monad
---     >>> import Control.Monad.Trans.Class
---     >>> import Control.Monad.Trans.Maybe
---     >>> import Data.Foldable
---     >>> let f !_ e = when (e > 3) mzero >> lift (print e)
---     >>> runMaybeT $ foldlM f () [0..]
+--     > :set -XBangPatterns
+--     > import Control.Monad
+--     > import Control.Monad.Trans.Class
+--     > import Control.Monad.Trans.Maybe
+--     > import Data.Foldable
+--     > let f !_ e = when (e > 3) mzero >> lift (print e)
+--     > runMaybeT $ foldlM f () [0..]
 --     0
 --     1
 --     2
@@ -553,16 +557,16 @@ import GHC.Internal.Data.Foldable
 --     to left, and therefore diverges when folding an unbounded input
 --     structure without ever having the opportunity to short-circuit.
 --
---     >>> let f e _ = when (e > 3) mzero >> lift (print e)
---     >>> runMaybeT $ foldrM f () [0..]
+--     > let f e _ = when (e > 3) mzero >> lift (print e)
+--     > runMaybeT $ foldrM f () [0..]
 --     ...hangs...
 --
 --     When the structure is finite `foldrM` performs the monadic effects from
 --     right to left, possibly short-circuiting after processing a tail portion
 --     of the element sequence.
 --
---     >>> let f e _ = when (e < 3) mzero >> lift (print e)
---     >>> runMaybeT $ foldrM f () [0..5]
+--     > let f e _ = when (e < 3) mzero >> lift (print e)
+--     > runMaybeT $ foldrM f () [0..5]
 --     5
 --     4
 --     3
@@ -614,14 +618,16 @@ import GHC.Internal.Data.Foldable
 -- Below we construct a @Foldable@ instance for a data type representing a
 -- (finite) binary tree with depth-first traversal.
 --
--- > data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
+-- >>> data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
 --
 -- a suitable instance would be:
 --
--- > instance Foldable Tree where
--- >    foldr f z Empty = z
--- >    foldr f z (Leaf x) = f x z
--- >    foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l
+-- >>> :{
+-- instance Foldable Tree where
+--    foldr f z Empty = z
+--    foldr f z (Leaf x) = f x z
+--    foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l
+-- :}
 --
 -- The 'Node' case is a right fold of the left subtree whose initial
 -- value is a right fold of the rest of the tree.


=====================================
libraries/base/src/Data/Foldable1.hs
=====================================
@@ -61,6 +61,9 @@ import GHC.Internal.Data.Coerce (Coercible, coerce)
 
 -- $setup
 -- >>> import Prelude hiding (foldr1, foldl1, head, last, minimum, maximum)
+-- >>> import Data.List.NonEmpty (NonEmpty(..))
+-- >>> import Data.Monoid (Sum(..))
+-- >>> import Data.Functor.Identity
 
 -------------------------------------------------------------------------------
 -- Foldable1 type class


=====================================
libraries/base/src/Data/Functor.hs
=====================================
@@ -11,32 +11,9 @@
 -- Portability :  portable
 --
 --
--- A type @f@ is a Functor if it provides a function @fmap@ which, given any types @a@ and @b@,
+-- A type @f@ is a Functor if it provides a function 'fmap' which, given any types @a@ and @b@,
 -- lets you apply any function of type @(a -> b)@ to turn an @f a@ into an @f b@, preserving the
 -- structure of @f at .
---
--- ==== __Examples__
---
---  >>> fmap show (Just 1)  --  (a   -> b)      -> f a       -> f b
---  Just "1"                --  (Int -> String) -> Maybe Int -> Maybe String
---
---  >>> fmap show Nothing   --  (a   -> b)      -> f a       -> f b
---  Nothing                 --  (Int -> String) -> Maybe Int -> Maybe String
---
---  >>> fmap show [1,2,3]   --  (a   -> b)      -> f a       -> f b
---  ["1","2","3"]           --  (Int -> String) -> [Int]     -> [String]
---
---  >>> fmap show []        --  (a   -> b)      -> f a       -> f b
---  []                      --  (Int -> String) -> [Int]     -> [String]
---
--- The 'fmap' function is also available as the infix operator '<$>':
---
---  >>> fmap show (Just 1) --  (Int -> String) -> Maybe Int -> Maybe String
---  Just "1"
---
---  >>> show <$> (Just 1)  --  (Int -> String) -> Maybe Int -> Maybe String
---  Just "1"
-
 module Data.Functor
     (Functor(..),
      ($>),
@@ -46,4 +23,4 @@ module Data.Functor
      void
      ) where
 
-import GHC.Internal.Data.Functor
\ No newline at end of file
+import GHC.Internal.Data.Functor


=====================================
libraries/base/src/Data/Functor/Compose.hs
=====================================
@@ -40,6 +40,9 @@ import Prelude
 
 infixr 9 `Compose`
 
+-- $setup
+-- >>> import Prelude
+
 -- | Right-to-left composition of functors.
 -- The composition of applicative functors is always applicative,
 -- but the composition of monads is not always a monad.


=====================================
libraries/base/src/Data/Functor/Product.hs
=====================================
@@ -31,6 +31,9 @@ import Data.Functor.Classes
 import GHC.Generics (Generic, Generic1)
 import Prelude
 
+-- $setup
+-- >>> import Prelude
+
 -- | Lifted product of functors.
 --
 -- ==== __Examples__


=====================================
libraries/base/src/Data/Functor/Sum.hs
=====================================
@@ -28,6 +28,9 @@ import Data.Functor.Classes
 import GHC.Generics (Generic, Generic1)
 import Prelude
 
+-- $setup
+-- >>> import Prelude
+
 -- | Lifted sum of functors.
 --
 -- ==== __Examples__


=====================================
libraries/base/src/Data/List/NonEmpty.hs
=====================================
@@ -120,7 +120,9 @@ import           GHC.Internal.Stack.Types     (HasCallStack)
 infixr 5 <|
 
 -- $setup
--- >>> import Prelude (negate)
+-- >>> import Prelude
+-- >>> import qualified Data.List as List
+-- >>> import Data.Ord (comparing)
 
 -- | Number of elements in 'NonEmpty' list.
 length :: NonEmpty a -> Int
@@ -205,7 +207,7 @@ sort = lift List.sort
 -- >>> sortOn fst $ (2, "world") :| [(4, "!"), (1, "Hello")]
 -- (1,"Hello") :| [(2,"world"),(4,"!")]
 --
--- >>> sortOn length $ "jim" :| ["creed", "pam", "michael", "dwight", "kevin"]
+-- >>> sortOn List.length ("jim" :| ["creed", "pam", "michael", "dwight", "kevin"])
 -- "jim" :| ["pam","creed","kevin","dwight","michael"]
 --
 -- ==== __Performance notes__
@@ -437,7 +439,7 @@ partition p = List.partition p . toList
 -- For example, in list notation:
 --
 -- >>> group "Mississippi"
--- ["M", "i", "ss", "i", "ss", "i", "pp", "i"]
+-- ['M' :| "",'i' :| "",'s' :| "s",'i' :| "",'s' :| "s",'i' :| "",'p' :| "p",'i' :| ""]
 group :: (Foldable f, Eq a) => f a -> [NonEmpty a]
 group = groupBy (==)
 


=====================================
libraries/base/src/Data/Monoid.hs
=====================================
@@ -24,6 +24,7 @@
 --
 -- The 'Sum' monoid is defined by the numerical addition operator and `0` as neutral element:
 --
+-- >>> import Data.Int
 -- >>> mempty :: Sum Int
 -- Sum {getSum = 0}
 -- >>> Sum 1 <> Sum 2 <> Sum 3 <> Sum 4 :: Sum Int
@@ -72,4 +73,5 @@ module Data.Monoid
      Ap(..)
      ) where
 
-import GHC.Internal.Data.Monoid
\ No newline at end of file
+import GHC.Internal.Data.Monoid
+


=====================================
libraries/base/src/Data/Semigroup.hs
=====================================
@@ -38,10 +38,14 @@
 -- can never be empty:
 --
 -- >>> (1 :| [])
--- 1 :| []               -- equivalent to [1] but guaranteed to be non-empty.
+-- 1 :| []
+--
+-- -- equivalent to [1] but guaranteed to be non-empty.
 --
 -- >>> (1 :| [2, 3, 4])
--- 1 :| [2,3,4]          -- equivalent to [1,2,3,4] but guaranteed to be non-empty.
+-- 1 :| [2,3,4]
+--
+-- -- equivalent to [1,2,3,4] but guaranteed to be non-empty.
 --
 -- Equipped with this guaranteed to be non-empty data structure, we can combine
 -- values using 'sconcat' and a 'Semigroup' of our choosing. We can try the 'Min'
@@ -122,6 +126,7 @@ import qualified GHC.Internal.List as List
 -- $setup
 -- >>> import Prelude
 -- >>> import Data.List.NonEmpty (NonEmpty (..))
+-- >>> import GHC.Internal.Data.Semigroup.Internal
 
 -- | A generalization of 'GHC.Internal.Data.List.cycle' to an arbitrary 'Semigroup'.
 -- May fail to terminate for some values in some semigroups.
@@ -135,7 +140,7 @@ import qualified GHC.Internal.List as List
 -- Right 1
 --
 -- >>> cycle1 (Left 1)
--- * hangs forever *
+-- * Hangs forever *
 cycle1 :: Semigroup m => m -> m
 cycle1 xs = xs' where xs' = xs <> xs'
 
@@ -143,7 +148,7 @@ cycle1 xs = xs' where xs' = xs <> xs'
 --
 -- ==== __Examples__
 --
--- > let hello = diff "Hello, "
+-- >>> let hello = diff "Hello, "
 --
 -- >>> appEndo hello "World!"
 -- "Hello, World!"
@@ -154,8 +159,8 @@ cycle1 xs = xs' where xs' = xs <> xs'
 -- >>> appEndo (mempty <> hello) "World!"
 -- "Hello, World!"
 --
--- > let world = diff "World"
--- > let excl = diff "!"
+-- >>> let world = diff "World"
+-- >>> let excl = diff "!"
 --
 -- >>> appEndo (hello <> (world <> excl)) mempty
 -- "Hello, World!"
@@ -171,7 +176,7 @@ diff = Endo . (<>)
 -- ==== __Examples__
 --
 -- >>> Min 42 <> Min 3
--- Min 3
+-- Min {getMin = 3}
 --
 -- >>> sconcat $ Min 1 :| [ Min n | n <- [2 .. 100]]
 -- Min {getMin = 1}
@@ -256,7 +261,7 @@ instance Num a => Num (Min a) where
 -- ==== __Examples__
 --
 -- >>> Max 42 <> Max 3
--- Max 42
+-- Max {getMax = 42}
 --
 -- >>> sconcat $ Max 1 :| [ Max n | n <- [2 .. 100]]
 -- Max {getMax = 100}
@@ -428,10 +433,10 @@ instance Bifoldable Arg where
 -- ==== __Examples__
 --
 -- >>> First 0 <> First 10
--- First 0
+-- First {getFirst = 0}
 --
 -- >>> sconcat $ First 1 :| [ First n | n <- [2 ..] ]
--- First 1
+-- First {getFirst = 1}
 newtype First a = First { getFirst :: a }
   deriving ( Bounded  -- ^ @since 4.9.0.0
            , Eq       -- ^ @since 4.9.0.0
@@ -502,7 +507,7 @@ instance MonadFix First where
 -- Last {getLast = 10}
 --
 -- >>> sconcat $ Last 1 :| [ Last n | n <- [2..]]
--- Last {getLast = * hangs forever *
+-- * Hangs forever *
 newtype Last a = Last { getLast :: a }
   deriving ( Bounded  -- ^ @since 4.9.0.0
            , Eq       -- ^ @since 4.9.0.0
@@ -629,7 +634,7 @@ instance Enum a => Enum (WrappedMonoid a) where
 -- ==== __Examples__
 --
 -- >>> mtimesDefault 0 "bark"
--- []
+-- ""
 --
 -- >>> mtimesDefault 3 "meow"
 -- "meowmeowmeow"


=====================================
libraries/base/src/Data/Traversable.hs
=====================================
@@ -86,6 +86,13 @@ module Data.Traversable (
 
 import GHC.Internal.Data.Traversable
 
+-- $setup
+-- >>> import Prelude
+-- >>> import Data.Maybe
+-- >>> import Data.Either
+-- >>> import qualified Data.List as List
+-- >>> :set -XExplicitForAll
+
 -- $overview
 --
 -- #overview#
@@ -201,13 +208,13 @@ import GHC.Internal.Data.Traversable
 -- __ at a@__), the result of __ at mapM g ts at __ will contain multiple structures of
 -- the same shape as __ at ts@__:
 --
--- prop> length (mapM g ts) == product (fmap (length . g) ts)
+-- prop> List.length (mapM g ts) == List.product (fmap (List.length . g) ts)
 --
 -- For example:
 --
--- >>> length $ mapM (\n -> [1..n]) [1..6]
+-- >>> List.length $ mapM (\n -> [1..n]) [1..6]
 -- 720
--- >>> product $ length . (\n -> [1..n]) <$> [1..6]
+-- >>> List.product $ List.length . (\n -> [1..n]) <$> [1..6]
 -- 720
 --
 -- In other words, a traversal with a function __ at g :: a -> [b]@__, over an
@@ -1006,14 +1013,16 @@ import GHC.Internal.Data.Traversable
 -- used to implicitly wrap and unwrap the @ZipList@ @newtype@ as needed, giving
 -- a function that operates on a list of lists:
 --
--- >>> {-# LANGUAGE ScopedTypeVariables #-}
+-- >>> :set -XScopedTypeVariables
 -- >>> import Control.Applicative (ZipList(..))
 -- >>> import Data.Coerce (coerce)
 -- >>>
--- >>> transpose :: forall a. [[a]] -> [[a]]
--- >>> transpose = coerce (sequenceA :: [ZipList a] -> ZipList [a])
--- >>>
--- >>> transpose [[1,2,3],[4..],[7..]]
+-- >>> :{
+-- >>> let
+-- >>>     transpose :: forall a. [[a]] -> [[a]]
+-- >>>     transpose = coerce (sequenceA :: [ZipList a] -> ZipList [a])
+-- >>> in transpose [[1,2,3],[4..],[7..]]
+-- >>> :}
 -- [[1,4,7],[2,5,8],[3,6,9]]
 --
 -- The use of [coercion](#coercion) avoids the need to explicitly wrap and


=====================================
libraries/base/src/System/IO.hs
=====================================
@@ -212,7 +212,7 @@ import GHC.Internal.System.IO
 --
 -- ==== __Example__
 --
--- >>> foo
+-- ghci> foo
 -- > input
 -- output
 -- > input^D


=====================================
libraries/ghc-internal/src/GHC/Internal/Base.hs
=====================================
@@ -971,7 +971,7 @@ for an explanation.
 class Functor f where
     -- | 'fmap' is used to apply a function of type @(a -> b)@ to a value of type @f a@,
     -- where f is a functor, to produce a value of type @f b at .
-    -- Note that for any type constructor with more than one parameter (e.g., `Either`),
+    -- Note that for any type constructor with more than one parameter (e.g., 'Either'),
     -- only the last type parameter can be modified with `fmap` (e.g., `b` in `Either a b`).
     --
     -- Some type constructors with two parameters or more have a @'Data.Bifunctor'@ instance that allows


=====================================
libraries/ghc-internal/src/GHC/Internal/Data/Monoid.hs
=====================================
@@ -29,6 +29,7 @@
 --
 -- The 'Sum' monoid is defined by the numerical addition operator and `0` as neutral element:
 --
+-- >>> import Data.Int (Int)
 -- >>> mempty :: Sum Int
 -- Sum {getSum = 0}
 -- >>> Sum 1 <> Sum 2 <> Sum 3 <> Sum 4 :: Sum Int
@@ -78,6 +79,9 @@ module GHC.Internal.Data.Monoid (
         Ap(..)
   ) where
 
+-- $setup
+-- >>> import Data.Int
+
 -- Push down the module in the dependency hierarchy.
 import GHC.Internal.Base hiding (Any)
 import GHC.Internal.Enum
@@ -299,6 +303,3 @@ prop_mconcatLast x =
         where listLastToMaybe [] = Nothing
               listLastToMaybe lst = Just (last lst)
 -- -}
-
--- $setup
--- >>> import Prelude



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3bad5d5550977eddf10ef1922c13984ba8646154

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3bad5d5550977eddf10ef1922c13984ba8646154
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240522/7e34ba0a/attachment-0001.html>


More information about the ghc-commits mailing list