Commit abc02b40 authored by Hécate Moonlight's avatar Hécate Moonlight Committed by Marge Bot

Annotate the non-total function in Data.Foldable as such

parent 373621f6
Pipeline #17029 failed with stages
in 455 minutes and 58 seconds
......@@ -215,6 +215,8 @@ class Foldable t where
-- | A variant of 'foldr' that has no base case,
-- and thus may only be applied to non-empty structures.
--
-- ⚠️ This function is non-total and will raise a runtime exception if the structure happens to be empty.
--
-- @'foldr1' f = 'List.foldr1' f . 'toList'@
foldr1 :: (a -> a -> a) -> t a -> a
foldr1 f xs = fromMaybe (errorWithoutStackTrace "foldr1: empty structure")
......@@ -227,6 +229,8 @@ class Foldable t where
-- | A variant of 'foldl' that has no base case,
-- and thus may only be applied to non-empty structures.
--
-- ⚠️ This function is non-total and will raise a runtime exception if the structure happens to be empty.
--
-- @'foldl1' f = 'List.foldl1' f . 'toList'@
foldl1 :: (a -> a -> a) -> t a -> a
foldl1 f xs = fromMaybe (errorWithoutStackTrace "foldl1: empty structure")
......@@ -267,6 +271,14 @@ class Foldable t where
-- | The largest element of a non-empty structure.
--
-- ⚠️ This function is non-total and will raise a runtime exception if the structure happens to be empty.
--
-- === __Examples__
-- >>> maximum [1..10]
-- 10
-- >>> maximum []
-- *** Exception: Prelude.maximum: empty list
--
-- @since 4.8.0.0
maximum :: forall a . Ord a => t a -> a
maximum = fromMaybe (errorWithoutStackTrace "maximum: empty structure") .
......@@ -274,6 +286,14 @@ class Foldable t where
-- | The least element of a non-empty structure.
--
-- ⚠️ This function is non-total and will raise a runtime exception if the structure happens to be empty
--
-- === __Examples__
-- >>> minimum [1..10]
-- 1
-- >>> minimum []
-- *** Exception: Prelude.minimum: empty list
--
-- @since 4.8.0.0
minimum :: forall a . Ord a => t a -> a
minimum = fromMaybe (errorWithoutStackTrace "minimum: empty structure") .
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment