diff --git a/libraries/base/Data/Foldable.hs b/libraries/base/Data/Foldable.hs
index f5f3112..cc0f348 100644
--- a/libraries/base/Data/Foldable.hs
+++ b/libraries/base/Data/Foldable.hs
@@ -1,766 +1,772 @@
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeOperators #-}
-----------------------------------------------------------------------------
-- |
-- Module : Data.Foldable
-- Copyright : Ross Paterson 2005
-- License : BSD-style (see the LICENSE file in the distribution)
--
-- Maintainer : libraries@haskell.org
-- Stability : experimental
-- Portability : portable
--
-- Class of data structures that can be folded to a summary value.
--
-----------------------------------------------------------------------------
module Data.Foldable (
Foldable(..),
-- * Special biased folds
foldrM,
foldlM,
-- * Folding actions
-- ** Applicative actions
traverse_,
for_,
sequenceA_,
asum,
-- ** Monadic actions
mapM_,
forM_,
sequence_,
msum,
-- * Specialized folds
concat,
concatMap,
and,
or,
any,
all,
maximumBy,
minimumBy,
-- * Searches
notElem,
find
) where
import Data.Bool
import Data.Either
import Data.Eq
import Data.Functor.Utils (Max(..), Min(..), (#.))
import qualified GHC.List as List
import Data.Maybe
import Data.Monoid
import Data.Ord
import Data.Proxy
import GHC.Arr ( Array(..), elems, numElements,
foldlElems, foldrElems,
foldlElems', foldrElems',
foldl1Elems, foldr1Elems)
import GHC.Base hiding ( foldr )
import GHC.Generics
import GHC.Num ( Num(..) )
infix 4 `elem`, `notElem`
-- | Data structures that can be folded.
--
-- For example, given a data type
--
-- > data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
--
-- a suitable instance would be
--
-- > instance Foldable Tree where
-- > foldMap f Empty = mempty
-- > foldMap f (Leaf x) = f x
-- > foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r
--
-- This is suitable even for abstract types, as the monoid is assumed
-- to satisfy the monoid laws. Alternatively, one could define @foldr@:
--
-- > 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
--
-- @Foldable@ instances are expected to satisfy the following laws:
--
-- > foldr f z t = appEndo (foldMap (Endo . f) t ) z
--
-- > foldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z
--
-- > fold = foldMap id
--
-- > length = getSum . foldMap (Sum . const 1)
--
-- @sum@, @product@, @maximum@, and @minimum@ should all be essentially
-- equivalent to @foldMap@ forms, such as
--
-- > sum = getSum . foldMap Sum
--
-- but may be less defined.
--
-- If the type is also a 'Functor' instance, it should satisfy
--
-- > foldMap f = fold . fmap f
--
-- which implies that
--
-- > foldMap f . fmap g = foldMap (f . g)
class Foldable t where
{-# MINIMAL foldMap | foldr #-}
-- | Combine the elements of a structure using a monoid.
fold :: Monoid m => t m -> m
fold = foldMap id
-- | Map each element of the structure to a monoid,
-- and combine the results.
foldMap :: Monoid m => (a -> m) -> t a -> m
{-# INLINE foldMap #-}
-- This INLINE allows more list functions to fuse. See Trac #9848.
foldMap f = foldr (mappend . f) mempty
+ -- | A variant of 'foldMap' that is strict in the accumulator.
+ --
+ -- @since 4.13.0.0
+ foldMap' :: Monoid m => (a -> m) -> t a -> m
+ foldMap' f = foldl' (\ acc a -> acc <> f a) mempty
+
-- | Right-associative fold of a structure.
--
-- In the case of lists, 'foldr', when applied to a binary operator, a
-- starting value (typically the right-identity of the operator), and a
-- list, reduces the list using the binary operator, from right to left:
--
-- > foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
--
-- Note that, since the head of the resulting expression is produced by
-- an application of the operator to the first element of the list,
-- 'foldr' can produce a terminating expression from an infinite list.
--
-- For a general 'Foldable' structure this should be semantically identical
-- to,
--
-- @foldr f z = 'List.foldr' f z . 'toList'@
--
foldr :: (a -> b -> b) -> b -> t a -> b
foldr f z t = appEndo (foldMap (Endo #. f) t) z
-- | Right-associative fold of a structure, but with strict application of
-- the operator.
--
foldr' :: (a -> b -> b) -> b -> t a -> b
foldr' f z0 xs = foldl f' id xs z0
where f' k x z = k $! f x z
-- | Left-associative fold of a structure.
--
-- In the case of lists, 'foldl', when applied to a binary
-- operator, a starting value (typically the left-identity of the operator),
-- and a list, reduces the list using the binary operator, from left to
-- right:
--
-- > foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
--
-- Note that to produce the outermost application of the operator the
-- entire input list must be traversed. This means that 'foldl'' will
-- diverge if given an infinite list.
--
-- Also note that if you want an efficient left-fold, you probably want to
-- use 'foldl'' instead of 'foldl'. The reason for this is that latter does
-- not force the "inner" results (e.g. @z \`f\` x1@ in the above example)
-- before applying them to the operator (e.g. to @(\`f\` x2)@). This results
-- in a thunk chain @O(n)@ elements long, which then must be evaluated from
-- the outside-in.
--
-- For a general 'Foldable' structure this should be semantically identical
-- to,
--
-- @foldl f z = 'List.foldl' f z . 'toList'@
--
foldl :: (b -> a -> b) -> b -> t a -> b
foldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z
-- There's no point mucking around with coercions here,
-- because flip forces us to build a new function anyway.
-- | Left-associative fold of a structure but with strict application of
-- the operator.
--
-- This ensures that each step of the fold is forced to weak head normal
-- form before being applied, avoiding the collection of thunks that would
-- otherwise occur. This is often what you want to strictly reduce a finite
-- list to a single, monolithic result (e.g. 'length').
--
-- For a general 'Foldable' structure this should be semantically identical
-- to,
--
-- @foldl f z = 'List.foldl'' f z . 'toList'@
--
foldl' :: (b -> a -> b) -> b -> t a -> b
foldl' f z0 xs = foldr f' id xs z0
where f' x k z = k $! f z x
-- | A variant of 'foldr' that has no base case,
-- and thus may only be applied to non-empty structures.
--
-- @'foldr1' f = 'List.foldr1' f . 'toList'@
foldr1 :: (a -> a -> a) -> t a -> a
foldr1 f xs = fromMaybe (errorWithoutStackTrace "foldr1: empty structure")
(foldr mf Nothing xs)
where
mf x m = Just (case m of
Nothing -> x
Just y -> f x y)
-- | A variant of 'foldl' that has no base case,
-- and thus may only be applied to non-empty structures.
--
-- @'foldl1' f = 'List.foldl1' f . 'toList'@
foldl1 :: (a -> a -> a) -> t a -> a
foldl1 f xs = fromMaybe (errorWithoutStackTrace "foldl1: empty structure")
(foldl mf Nothing xs)
where
mf m y = Just (case m of
Nothing -> y
Just x -> f x y)
-- | List of elements of a structure, from left to right.
toList :: t a -> [a]
{-# INLINE toList #-}
toList t = build (\ c n -> foldr c n t)
-- | Test whether the structure is empty. The default implementation is
-- optimized for structures that are similar to cons-lists, because there
-- is no general way to do better.
null :: t a -> Bool
null = foldr (\_ _ -> False) True
-- | Returns the size/length of a finite structure as an 'Int'. The
-- default implementation is optimized for structures that are similar to
-- cons-lists, because there is no general way to do better.
length :: t a -> Int
length = foldl' (\c _ -> c+1) 0
-- | Does the element occur in the structure?
elem :: Eq a => a -> t a -> Bool
elem = any . (==)
-- | The largest element of a non-empty structure.
maximum :: forall a . Ord a => t a -> a
maximum = fromMaybe (errorWithoutStackTrace "maximum: empty structure") .
getMax . foldMap (Max #. (Just :: a -> Maybe a))
-- | The least element of a non-empty structure.
minimum :: forall a . Ord a => t a -> a
minimum = fromMaybe (errorWithoutStackTrace "minimum: empty structure") .
getMin . foldMap (Min #. (Just :: a -> Maybe a))
-- | The 'sum' function computes the sum of the numbers of a structure.
sum :: Num a => t a -> a
sum = getSum #. foldMap Sum
-- | The 'product' function computes the product of the numbers of a
-- structure.
product :: Num a => t a -> a
product = getProduct #. foldMap Product
-- instances for Prelude types
-- | @since 2.01
instance Foldable Maybe where
foldMap = maybe mempty
foldr _ z Nothing = z
foldr f z (Just x) = f x z
foldl _ z Nothing = z
foldl f z (Just x) = f z x
-- | @since 2.01
instance Foldable [] where
elem = List.elem
foldl = List.foldl
foldl' = List.foldl'
foldl1 = List.foldl1
foldr = List.foldr
foldr1 = List.foldr1
length = List.length
maximum = List.maximum
minimum = List.minimum
null = List.null
product = List.product
sum = List.sum
toList = id
-- | @since 4.9.0.0
instance Foldable NonEmpty where
foldr f z ~(a :| as) = f a (List.foldr f z as)
foldl f z (a :| as) = List.foldl f (f z a) as
foldl1 f (a :| as) = List.foldl f a as
-- GHC isn't clever enough to transform the default definition
-- into anything like this, so we'd end up shuffling a bunch of
-- Maybes around.
foldr1 f (p :| ps) = foldr go id ps p
where
go x r prev = f prev (r x)
-- We used to say
--
-- length (_ :| as) = 1 + length as
--
-- but the default definition is better, counting from 1.
--
-- The default definition also works great for null and foldl'.
-- As usual for cons lists, foldr' is basically hopeless.
foldMap f ~(a :| as) = f a `mappend` foldMap f as
fold ~(m :| ms) = m `mappend` fold ms
toList ~(a :| as) = a : as
-- | @since 4.7.0.0
instance Foldable (Either a) where
foldMap _ (Left _) = mempty
foldMap f (Right y) = f y
foldr _ z (Left _) = z
foldr f z (Right y) = f y z
length (Left _) = 0
length (Right _) = 1
null = isLeft
-- | @since 4.7.0.0
instance Foldable ((,) a) where
foldMap f (_, y) = f y
foldr f z (_, y) = f y z
-- | @since 4.8.0.0
instance Foldable (Array i) where
foldr = foldrElems
foldl = foldlElems
foldl' = foldlElems'
foldr' = foldrElems'
foldl1 = foldl1Elems
foldr1 = foldr1Elems
toList = elems
length = numElements
null a = numElements a == 0
-- | @since 4.7.0.0
instance Foldable Proxy where
foldMap _ _ = mempty
{-# INLINE foldMap #-}
fold _ = mempty
{-# INLINE fold #-}
foldr _ z _ = z
{-# INLINE foldr #-}
foldl _ z _ = z
{-# INLINE foldl #-}
foldl1 _ _ = errorWithoutStackTrace "foldl1: Proxy"
foldr1 _ _ = errorWithoutStackTrace "foldr1: Proxy"
length _ = 0
null _ = True
elem _ _ = False
sum _ = 0
product _ = 1
-- | @since 4.8.0.0
instance Foldable Dual where
foldMap = coerce
elem = (. getDual) #. (==)
foldl = coerce
foldl' = coerce
foldl1 _ = getDual
foldr f z (Dual x) = f x z
foldr' = foldr
foldr1 _ = getDual
length _ = 1
maximum = getDual
minimum = getDual
null _ = False
product = getDual
sum = getDual
toList (Dual x) = [x]
-- | @since 4.8.0.0
instance Foldable Sum where
foldMap = coerce
elem = (. getSum) #. (==)
foldl = coerce
foldl' = coerce
foldl1 _ = getSum
foldr f z (Sum x) = f x z
foldr' = foldr
foldr1 _ = getSum
length _ = 1
maximum = getSum
minimum = getSum
null _ = False
product = getSum
sum = getSum
toList (Sum x) = [x]
-- | @since 4.8.0.0
instance Foldable Product where
foldMap = coerce
elem = (. getProduct) #. (==)
foldl = coerce
foldl' = coerce
foldl1 _ = getProduct
foldr f z (Product x) = f x z
foldr' = foldr
foldr1 _ = getProduct
length _ = 1
maximum = getProduct
minimum = getProduct
null _ = False
product = getProduct
sum = getProduct
toList (Product x) = [x]
-- | @since 4.8.0.0
instance Foldable First where
foldMap f = foldMap f . getFirst
-- | @since 4.8.0.0
instance Foldable Last where
foldMap f = foldMap f . getLast
-- | @since 4.12.0.0
instance (Foldable f) => Foldable (Alt f) where
foldMap f = foldMap f . getAlt
-- | @since 4.12.0.0
instance (Foldable f) => Foldable (Ap f) where
foldMap f = foldMap f . getAp
-- Instances for GHC.Generics
-- | @since 4.9.0.0
instance Foldable U1 where
foldMap _ _ = mempty
{-# INLINE foldMap #-}
fold _ = mempty
{-# INLINE fold #-}
foldr _ z _ = z
{-# INLINE foldr #-}
foldl _ z _ = z
{-# INLINE foldl #-}
foldl1 _ _ = errorWithoutStackTrace "foldl1: U1"
foldr1 _ _ = errorWithoutStackTrace "foldr1: U1"
length _ = 0
null _ = True
elem _ _ = False
sum _ = 0
product _ = 1
-- | @since 4.9.0.0
deriving instance Foldable V1
-- | @since 4.9.0.0
deriving instance Foldable Par1
-- | @since 4.9.0.0
deriving instance Foldable f => Foldable (Rec1 f)
-- | @since 4.9.0.0
deriving instance Foldable (K1 i c)
-- | @since 4.9.0.0
deriving instance Foldable f => Foldable (M1 i c f)
-- | @since 4.9.0.0
deriving instance (Foldable f, Foldable g) => Foldable (f :+: g)
-- | @since 4.9.0.0
deriving instance (Foldable f, Foldable g) => Foldable (f :*: g)
-- | @since 4.9.0.0
deriving instance (Foldable f, Foldable g) => Foldable (f :.: g)
-- | @since 4.9.0.0
deriving instance Foldable UAddr
-- | @since 4.9.0.0
deriving instance Foldable UChar
-- | @since 4.9.0.0
deriving instance Foldable UDouble
-- | @since 4.9.0.0
deriving instance Foldable UFloat
-- | @since 4.9.0.0
deriving instance Foldable UInt
-- | @since 4.9.0.0
deriving instance Foldable UWord
-- Instances for Data.Ord
-- | @since 4.12.0.0
deriving instance Foldable Down
-- | Monadic fold over the elements of a structure,
-- associating to the right, i.e. from right to left.
foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b
foldrM f z0 xs = foldl c return xs z0
-- See Note [List fusion and continuations in 'c']
where c k x z = f x z >>= k
{-# INLINE c #-}
-- | Monadic fold over the elements of a structure,
-- associating to the left, i.e. from left to right.
foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
foldlM f z0 xs = foldr c return xs z0
-- See Note [List fusion and continuations in 'c']
where c x k z = f z x >>= k
{-# INLINE c #-}
-- | Map each element of a structure to an action, evaluate these
-- actions from left to right, and ignore the results. For a version
-- that doesn't ignore the results see 'Data.Traversable.traverse'.
traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
traverse_ f = foldr c (pure ())
-- See Note [List fusion and continuations in 'c']
where c x k = f x *> k
{-# INLINE c #-}
-- | 'for_' is 'traverse_' with its arguments flipped. For a version
-- that doesn't ignore the results see 'Data.Traversable.for'.
--
-- >>> for_ [1..4] print
-- 1
-- 2
-- 3
-- 4
for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
{-# INLINE for_ #-}
for_ = flip traverse_
-- | Map each element of a structure to a monadic action, evaluate
-- these actions from left to right, and ignore the results. For a
-- version that doesn't ignore the results see
-- 'Data.Traversable.mapM'.
--
-- As of base 4.8.0.0, 'mapM_' is just 'traverse_', specialized to
-- 'Monad'.
mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
mapM_ f = foldr c (return ())
-- See Note [List fusion and continuations in 'c']
where c x k = f x >> k
{-# INLINE c #-}
-- | 'forM_' is 'mapM_' with its arguments flipped. For a version that
-- doesn't ignore the results see 'Data.Traversable.forM'.
--
-- As of base 4.8.0.0, 'forM_' is just 'for_', specialized to 'Monad'.
forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()
{-# INLINE forM_ #-}
forM_ = flip mapM_
-- | Evaluate each action in the structure from left to right, and
-- ignore the results. For a version that doesn't ignore the results
-- see 'Data.Traversable.sequenceA'.
sequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f ()
sequenceA_ = foldr c (pure ())
-- See Note [List fusion and continuations in 'c']
where c m k = m *> k
{-# INLINE c #-}
-- | Evaluate each monadic action in the structure from left to right,
-- and ignore the results. For a version that doesn't ignore the
-- results see 'Data.Traversable.sequence'.
--
-- As of base 4.8.0.0, 'sequence_' is just 'sequenceA_', specialized
-- to 'Monad'.
sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()
sequence_ = foldr c (return ())
-- See Note [List fusion and continuations in 'c']
where c m k = m >> k
{-# INLINE c #-}
-- | The sum of a collection of actions, generalizing 'concat'.
--
-- >>> asum [Just "Hello", Nothing, Just "World"]
-- Just "Hello"
asum :: (Foldable t, Alternative f) => t (f a) -> f a
{-# INLINE asum #-}
asum = foldr (<|>) empty
-- | The sum of a collection of actions, generalizing 'concat'.
-- As of base 4.8.0.0, 'msum' is just 'asum', specialized to 'MonadPlus'.
msum :: (Foldable t, MonadPlus m) => t (m a) -> m a
{-# INLINE msum #-}
msum = asum
-- | The concatenation of all the elements of a container of lists.
concat :: Foldable t => t [a] -> [a]
concat xs = build (\c n -> foldr (\x y -> foldr c y x) n xs)
{-# INLINE concat #-}
-- | Map a function over all the elements of a container and concatenate
-- the resulting lists.
concatMap :: Foldable t => (a -> [b]) -> t a -> [b]
concatMap f xs = build (\c n -> foldr (\x b -> foldr c b (f x)) n xs)
{-# INLINE concatMap #-}
-- These use foldr rather than foldMap to avoid repeated concatenation.
-- | 'and' returns the conjunction of a container of Bools. For the
-- result to be 'True', the container must be finite; 'False', however,
-- results from a 'False' value finitely far from the left end.
and :: Foldable t => t Bool -> Bool
and = getAll #. foldMap All
-- | 'or' returns the disjunction of a container of Bools. For the
-- result to be 'False', the container must be finite; 'True', however,
-- results from a 'True' value finitely far from the left end.
or :: Foldable t => t Bool -> Bool
or = getAny #. foldMap Any
-- | Determines whether any element of the structure satisfies the predicate.
any :: Foldable t => (a -> Bool) -> t a -> Bool
any p = getAny #. foldMap (Any #. p)
-- | Determines whether all elements of the structure satisfy the predicate.
all :: Foldable t => (a -> Bool) -> t a -> Bool
all p = getAll #. foldMap (All #. p)
-- | The largest element of a non-empty structure with respect to the
-- given comparison function.
-- See Note [maximumBy/minimumBy space usage]
maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
maximumBy cmp = foldl1 max'
where max' x y = case cmp x y of
GT -> x
_ -> y
-- | The least element of a non-empty structure with respect to the
-- given comparison function.
-- See Note [maximumBy/minimumBy space usage]
minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
minimumBy cmp = foldl1 min'
where min' x y = case cmp x y of
GT -> y
_ -> x
-- | 'notElem' is the negation of 'elem'.
notElem :: (Foldable t, Eq a) => a -> t a -> Bool
notElem x = not . elem x
-- | The 'find' function takes a predicate and a structure and returns
-- the leftmost element of the structure matching the predicate, or
-- 'Nothing' if there is no such element.
find :: Foldable t => (a -> Bool) -> t a -> Maybe a
find p = getFirst . foldMap (\ x -> First (if p x then Just x else Nothing))
{-
Note [List fusion and continuations in 'c']
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we define
mapM_ f = foldr ((>>) . f) (return ())
(this is the way it used to be).
Now suppose we want to optimise the call
mapM_ (build g)
where
g c n = ...(c x1 y1)...(c x2 y2)....n...
GHC used to proceed like this:
mapM_ (build g)
= { Defintion of mapM_ }
foldr ((>>) . ) (return ()) (build g)
= { foldr/build rule }
g ((>>) . ) (return ())
= { Inline g }
let c = (>>) .
n = return ()
in ...(c x1 y1)...(c x2 y2)....n...
The trouble is that `c`, being big, will not be inlined. And that can
be absolutely terrible for performance, as we saw in Trac #8763.
It's much better to define
mapM_ f = foldr c (return ())
where
c x k = f x >> k
{-# INLINE c #-}
Now we get
mapM_ (build g)
= { inline mapM_ }
foldr c (return ()) (build g)
where c x k = f x >> k
{-# INLINE c #-}
f =
Notice that `f` does not inline into the RHS of `c`,
because the INLINE pragma stops it; see
Note [Simplifying inside stable unfoldings] in SimplUtils.
Continuing:
= { foldr/build rule }
g c (return ())
where ...
c x k = f x >> k
{-# INLINE c #-}
f =
= { inline g }
...(c x1 y1)...(c x2 y2)....n...
where c x k = f x >> k
{-# INLINE c #-}
f =
n = return ()
Now, crucially, `c` does inline
= { inline c }
...(f x1 >> y1)...(f x2 >> y2)....n...
where f =
n = return ()
And all is well! The key thing is that the fragment
`(f x1 >> y1)` is inlined into the body of the builder
`g`.
-}
{-
Note [maximumBy/minimumBy space usage]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When the type signatures of maximumBy and minimumBy were generalized to work
over any Foldable instance (instead of just lists), they were defined using
foldr1. This was problematic for space usage, as the semantics of maximumBy
and minimumBy essentially require that they examine every element of the
data structure. Using foldr1 to examine every element results in space usage
proportional to the size of the data structure. For the common case of lists,
this could be particularly bad (see Trac #10830).
For the common case of lists, switching the implementations of maximumBy and
minimumBy to foldl1 solves the issue, as GHC's strictness analysis can then
make these functions only use O(1) stack space. It is perhaps not the optimal
way to fix this problem, as there are other conceivable data structures
(besides lists) which might benefit from specialized implementations for
maximumBy and minimumBy (see
https://ghc.haskell.org/trac/ghc/ticket/10830#comment:26 for a further
discussion). But using foldl1 is at least always better than using foldr1, so
GHC has chosen to adopt that approach for now.
-}
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index 3709a0a..bfa8cb9 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -1,747 +1,749 @@
# Changelog for [`base` package](http://hackage.haskell.org/package/base)
## 4.12.0.0 *TBA*
* Bundled with GHC *TBA*
* Support the characters from recent versions of Unicode (up to v. 12) in
literals (#5518).
* The `StableName` type parameter now has a phantom role instead of
a representational one. There is really no reason to care about the
type of the underlying object.
+ * Add `foldMap'`, a strict version of `foldMap`, to `Foldable`.
+
## 4.12.0.0 *TBA*
* Bundled with GHC *TBA*
* The STM invariant-checking mechanism (`always` and `alwaysSucceeds`), which
was deprecated in GHC 8.4, has been removed (as proposed in
).
This is a bit earlier than proposed in the deprecation pragma included in
GHC 8.4, but due to community feedback we decided to move ahead with the
early removal.
Existing users are encouraged to encapsulate their STM operations in safe
abstractions which can perform the invariant checking without help from the
runtime system.
* Add a new module `GHC.ResponseFile` (previously defined in the `haddock`
package). (#13896)
* Move the module `Data.Functor.Contravariant` from the
`contravariant` package to `base`.
* `($!)` is now representation-polymorphic like `($)`.
* Add `Applicative` (for `K1`), `Semigroup` and `Monoid` instances in
`GHC.Generics`. (#14849)
* `asinh` for `Float` and `Double` is now numerically stable in the face of
non-small negative arguments and enormous arguments of either sign. (#14927)
* `Numeric.showEFloat (Just 0)` now respects the user's requested precision.
(#15115)
* `Data.Monoid.Alt` now has `Foldable` and `Traversable` instances. (#15099)
* `Data.Monoid.Ap` has been introduced
* `Control.Exception.throw` is now levity polymorphic. (#15180)
* `Data.Ord.Down` now has a number of new instances. These include:
`MonadFix`, `MonadZip`, `Data`, `Foldable`, `Traversable`, `Eq1`, `Ord1`,
`Read1`, `Show1`, `Generic`, `Generic1`. (#15098)
## 4.11.1.0 *TBA*
* Bundled with GHC 8.4.2
* Add the `readFieldHash` function to `GHC.Read` which behaves like
`readField`, but for a field that ends with a `#` symbol (#14918).
## 4.11.0.0 *TBA*
* Bundled with GHC 8.4.1
* `System.IO.openTempFile` is now thread-safe on Windows.
* Deprecated `GHC.Stats.GCStats` interface has been removed.
* Add `showHFloat` to `Numeric`
* Add `Div`, `Mod`, and `Log2` functions on type-level naturals
in `GHC.TypeLits`.
* Add `Alternative` instance for `ZipList` (#13520)
* Add instances `Num`, `Functor`, `Applicative`, `Monad`, `Semigroup`
and `Monoid` for `Data.Ord.Down` (#13097).
* Add `Semigroup` instance for `EventLifetime`.
* Make `Semigroup` a superclass of `Monoid`;
export `Semigroup((<>))` from `Prelude`; remove `Monoid` reexport
from `Data.Semigroup` (#14191).
* Generalise `instance Monoid a => Monoid (Maybe a)` to
`instance Semigroup a => Monoid (Maybe a)`.
* Add `infixl 9 !!` declaration for `Data.List.NonEmpty.!!`
* Add `<&>` operator to `Data.Functor` (#14029)
* Remove the deprecated `Typeable{1..7}` type synonyms (#14047)
* Make `Data.Type.Equality.==` a closed type family. It now works for all
kinds out of the box. Any modules that previously declared instances of this
family will need to remove them. Whereas the previous definition was somewhat
ad hoc, the behavior is now completely uniform. As a result, some applications
that used to reduce no longer do, and conversely. Most notably, `(==)` no
longer treats the `*`, `j -> k`, or `()` kinds specially; equality is
tested structurally in all cases.
* Add instances `Semigroup` and `Monoid` for `Control.Monad.ST` (#14107).
* The `Read` instances for `Proxy`, `Coercion`, `(:~:)`, `(:~~:)`, and `U1`
now ignore the parsing precedence. The effect of this is that `read` will
be able to successfully parse more strings containing `"Proxy"` _et al._
without surrounding parentheses (e.g., `"Thing Proxy"`) (#12874).
* Add `iterate'`, a strict version of `iterate`, to `Data.List`
and `Data.OldList` (#3474)
* Add `Data` instances for `IntPtr` and `WordPtr` (#13115)
* Add missing `MonadFail` instance for `Control.Monad.Strict.ST.ST`
* Make `zipWith` and `zipWith3` inlinable (#14224)
* `Type.Reflection.App` now matches on function types (fixes #14236)
* `Type.Reflection.withTypeable` is now polymorphic in the `RuntimeRep` of
its result.
* Add `installSEHHandlers` to `MiscFlags` in `GHC.RTS.Flags` to determine if
exception handling is enabled.
* The deprecated functions `isEmptyChan` and `unGetChan` in
`Control.Concurrent.Chan` have been removed (#13561).
* Add `generateCrashDumpFile` to `MiscFlags` in `GHC.RTS.Flags` to determine
if a core dump will be generated on crashes.
* Add `generateStackTrace` to `MiscFlags` in `GHC.RTS.Flags` to determine if
stack traces will be generated on unhandled exceptions by the RTS.
* `getExecutablePath` now resolves symlinks on Windows (#14483)
* Deprecated STM invariant checking primitives (`checkInv`, `always`, and
`alwaysSucceeds`) in `GHC.Conc.Sync` (#14324).
* Add a `FixIOException` data type to `Control.Exception.Base`, and change
`fixIO` to throw that instead of a `BlockedIndefinitelyOnMVar` exception
(#14356).
## 4.10.1.0 *November 2017*
* Bundled with GHC 8.2.2
* The file locking primitives provided by `GHC.IO.Handle` now use
Linux open file descriptor locking if available.
* Fixed bottoming definition of `clearBit` for `Natural`
## 4.10.0.0 *July 2017*
* Bundled with GHC 8.2.1
* `Data.Type.Bool.Not` given a type family dependency (#12057).
* `Foreign.Ptr` now exports the constructors for `IntPtr` and `WordPtr`
(#11983)
* `Generic1`, as well as the associated datatypes and typeclasses in
`GHC.Generics`, are now poly-kinded (#10604)
* `New modules `Data.Bifoldable` and `Data.Bitraversable` (previously defined
in the `bifunctors` package) (#10448)
* `Data.Either` now provides `fromLeft` and `fromRight` (#12402)
* `Data.Type.Coercion` now provides `gcoerceWith` (#12493)
* New methods `liftReadList(2)` and `liftReadListPrec(2)` in the
`Read1`/`Read2` classes that are defined in terms of `ReadPrec` instead of
`ReadS`, as well as related combinators, have been added to
`Data.Functor.Classes` (#12358)
* Add `Semigroup` instance for `IO`, as well as for `Event` and `Lifetime`
from `GHC.Event` (#12464)
* Add `Data` instance for `Const` (#12438)
* Added `Eq1`, `Ord1`, `Read1` and `Show1` instances for `NonEmpty`.
* Add wrappers for `blksize_t`, `blkcnt_t`, `clockid_t`, `fsblkcnt_t`,
`fsfilcnt_t`, `id_t`, `key_t`, and `timer_t` to System.Posix.Types (#12795)
* Add `CBool`, a wrapper around C's `bool` type, to `Foreign.C.Types`
(#13136)
* Raw buffer operations in `GHC.IO.FD` are now strict in the buffer, offset, and length operations (#9696)
* Add `plusForeignPtr` to `Foreign.ForeignPtr`.
* Add `type family AppendSymbol (m :: Symbol) (n :: Symbol) :: Symbol` to `GHC.TypeLits`
(#12162)
* Add `GHC.TypeNats` module with `Natural`-based `KnownNat`. The `Nat`
operations in `GHC.TypeLits` are a thin compatibility layer on top.
Note: the `KnownNat` evidence is changed from an `Integer` to a `Natural`.
* The type of `asProxyTypeOf` in `Data.Proxy` has been generalized (#12805)
* `liftA2` is now a method of the `Applicative` class. `liftA2` and
`<*>` each have a default implementation based on the other. Various
library functions have been updated to use `liftA2` where it might offer
some benefit. `liftA2` is not yet in the `Prelude`, and must currently be
imported from `Control.Applicative`. It is likely to be added to the
`Prelude` in the future. (#13191)
* A new module, `Type.Reflection`, exposing GHC's new type-indexed type
representation mechanism is now provided.
* `Data.Dynamic` now exports the `Dyn` data constructor, enabled by the new
type-indexed type representation mechanism.
* `Data.Type.Equality` now provides a kind heterogeneous type equality
evidence type, `(:~~:)`.
* The `CostCentresXML` constructor of `GHC.RTS.Flags.DoCostCentres` has been
replaced by `CostCentresJSON` due to the new JSON export format supported by
the cost centre profiler.
* The `ErrorCall` pattern synonym has been given a `COMPLETE` pragma so that
functions which solely match again `ErrorCall` do not produce
non-exhaustive pattern-match warnings (#8779)
* Change the implementations of `maximumBy` and `minimumBy` from
`Data.Foldable` to use `foldl1` instead of `foldr1`. This makes them run
in constant space when applied to lists. (#10830)
* `mkFunTy`, `mkAppTy`, and `mkTyConApp` from `Data.Typeable` no longer exist.
This functionality is superceded by the interfaces provided by
`Type.Reflection`.
* `mkTyCon3` is no longer exported by `Data.Typeable`. This function is
replaced by `Type.Reflection.Unsafe.mkTyCon`.
* `Data.List.NonEmpty.unfold` has been deprecated in favor of `unfoldr`,
which is functionally equivalent.
## 4.9.0.0 *May 2016*
* Bundled with GHC 8.0
* `error` and `undefined` now print a partial stack-trace alongside the error message.
* New `errorWithoutStackTrace` function throws an error without printing the stack trace.
* The restore operation provided by `mask` and `uninterruptibleMask` now
restores the previous masking state whatever the current masking state is.
* New `GHC.Generics.packageName` operation
* Redesigned `GHC.Stack.CallStack` data type. As a result, `CallStack`'s
`Show` instance produces different output, and `CallStack` no longer has an
`Eq` instance.
* New `GHC.Generics.packageName` operation
* New `GHC.Stack.Types` module now contains the definition of
`CallStack` and `SrcLoc`
* New `GHC.Stack.Types.emptyCallStack` function builds an empty `CallStack`
* New `GHC.Stack.Types.freezeCallStack` function freezes a `CallStack` preventing future `pushCallStack` operations from having any effect
* New `GHC.Stack.Types.pushCallStack` function pushes a call-site onto a `CallStack`
* New `GHC.Stack.Types.fromCallSiteList` function creates a `CallStack` from
a list of call-sites (i.e., `[(String, SrcLoc)]`)
* `GHC.SrcLoc` has been removed
* `GHC.Stack.showCallStack` and `GHC.SrcLoc.showSrcLoc` are now called
`GHC.Stack.prettyCallStack` and `GHC.Stack.prettySrcLoc` respectively
* add `Data.List.NonEmpty` and `Data.Semigroup` (to become
super-class of `Monoid` in the future). These modules were
provided by the `semigroups` package previously. (#10365)
* Add `selSourceUnpackedness`, `selSourceStrictness`, and
`selDecidedStrictness`, three functions which look up strictness
information of a field in a data constructor, to the `Selector` type class
in `GHC.Generics` (#10716)
* Add `URec`, `UAddr`, `UChar`, `UDouble`, `UFloat`, `UInt`, and `UWord` to
`GHC.Generics` as part of making GHC generics capable of handling
unlifted types (#10868)
* The `Eq`, `Ord`, `Read`, and `Show` instances for `U1` now use lazier
pattern-matching
* Keep `shift{L,R}` on `Integer` with negative shift-arguments from
segfaulting (#10571)
* Add `forkOSWithUnmask` to `Control.Concurrent`, which is like
`forkIOWithUnmask`, but the child is run in a bound thread.
* The `MINIMAL` definition of `Arrow` is now `arr AND (first OR (***))`.
* The `MINIMAL` definition of `ArrowChoice` is now `left OR (+++)`.
* Exported `GiveGCStats`, `DoCostCentres`, `DoHeapProfile`, `DoTrace`,
`RtsTime`, and `RtsNat` from `GHC.RTS.Flags`
* New function `GHC.IO.interruptible` used to correctly implement
`Control.Exception.allowInterrupt` (#9516)
* Made `PatternMatchFail`, `RecSelError`, `RecConError`, `RecUpdError`,
`NoMethodError`, and `AssertionFailed` newtypes (#10738)
* New module `Control.Monad.IO.Class` (previously provided by `transformers`
package). (#10773)
* New modules `Data.Functor.Classes`, `Data.Functor.Compose`,
`Data.Functor.Product`, and `Data.Functor.Sum` (previously provided by
`transformers` package). (#11135)
* New instances for `Proxy`: `Eq1`, `Ord1`, `Show1`, `Read1`. All
of the classes are from `Data.Functor.Classes` (#11756).
* New module `Control.Monad.Fail` providing new `MonadFail(fail)`
class (#10751)
* Add `GHC.TypeLits.TypeError` and `ErrorMessage` to allow users
to define custom compile-time error messages.
* Redesign `GHC.Generics` to use type-level literals to represent the
metadata of generic representation types (#9766)
* The `IsString` instance for `[Char]` has been modified to eliminate
ambiguity arising from overloaded strings and functions like `(++)`.
* Move `Const` from `Control.Applicative` to its own module in
`Data.Functor.Const`. (#11135)
* Re-export `Const` from `Control.Applicative` for backwards compatibility.
* Expand `Floating` class to include operations that allow for better
precision: `log1p`, `expm1`, `log1pexp` and `log1mexp`. These are not
available from `Prelude`, but the full class is exported from `Numeric`.
* New `Control.Exception.TypeError` datatype, which is thrown when an
expression fails to typecheck when run using `-fdefer-type-errors` (#10284)
* The `bitSize` method of `Data.Bits.Bits` now has a (partial!)
default implementation based on `bitSizeMaybe`. (#12970)
### New instances
* `Alt`, `Dual`, `First`, `Last`, `Product`, and `Sum` now have `Data`,
`MonadZip`, and `MonadFix` instances
* The datatypes in `GHC.Generics` now have `Enum`, `Bounded`, `Ix`,
`Functor`, `Applicative`, `Monad`, `MonadFix`, `MonadPlus`, `MonadZip`,
`Foldable`, `Foldable`, `Traversable`, `Generic1`, and `Data` instances
as appropriate.
* `Maybe` now has a `MonadZip` instance
* `All` and `Any` now have `Data` instances
* `Dual`, `First`, `Last`, `Product`, and `Sum` now have `Foldable` and
`Traversable` instances
* `Dual`, `Product`, and `Sum` now have `Functor`, `Applicative`, and
`Monad` instances
* `(,) a` now has a `Monad` instance
* `ZipList` now has `Foldable` and `Traversable` instances
* `Identity` now has `Semigroup` and `Monoid` instances
* `Identity` and `Const` now have `Bits`, `Bounded`, `Enum`, `FiniteBits`,
`Floating`, `Fractional`, `Integral`, `IsString`, `Ix`, `Num`, `Real`,
`RealFloat`, `RealFrac` and `Storable` instances. (#11210, #11790)
* `()` now has a `Storable` instance
* `Complex` now has `Generic`, `Generic1`, `Functor`, `Foldable`, `Traversable`,
`Applicative`, and `Monad` instances
* `System.Exit.ExitCode` now has a `Generic` instance
* `Data.Version.Version` now has a `Generic` instance
* `IO` now has a `Monoid` instance
* Add `MonadPlus IO` and `Alternative IO` instances
(previously orphans in `transformers`) (#10755)
* `CallStack` now has an `IsList` instance
* The field `spInfoName` of `GHC.StaticPtr.StaticPtrInfo` has been removed.
The value is no longer available when constructing the `StaticPtr`.
* `VecElem` and `VecCount` now have `Enum` and `Bounded` instances.
### Generalizations
* Generalize `Debug.Trace.{traceM, traceShowM}` from `Monad` to `Applicative`
(#10023)
* Redundant typeclass constraints have been removed:
- `Data.Ratio.{denominator,numerator}` have no `Integral` constraint anymore
- **TODO**
* Generalise `forever` from `Monad` to `Applicative`
* Generalize `filterM`, `mapAndUnzipM`, `zipWithM`, `zipWithM_`, `replicateM`,
`replicateM_` from `Monad` to `Applicative` (#10168)
* The `Generic` instance for `Proxy` is now poly-kinded (#10775)
* Enable `PolyKinds` in the `Data.Functor.Const` module to give `Const`
the kind `* -> k -> *`. (#10039)
## 4.8.2.0 *Oct 2015*
* Bundled with GHC 7.10.3
* The restore operation provided by `mask` and `uninterruptibleMask` now
restores the previous masking state whatever the current masking state is.
* Exported `GiveGCStats`, `DoCostCentres`, `DoHeapProfile`, `DoTrace`,
`RtsTime`, and `RtsNat` from `GHC.RTS.Flags`
## 4.8.1.0 *Jul 2015*
* Bundled with GHC 7.10.2
* `Lifetime` is now exported from `GHC.Event`
* Implicit-parameter based source location support exposed in `GHC.SrcLoc` and `GHC.Stack`.
See GHC User's Manual for more information.
## 4.8.0.0 *Mar 2015*
* Bundled with GHC 7.10.1
* Make `Applicative` a superclass of `Monad`
* Add reverse application operator `Data.Function.(&)`
* Add `Data.List.sortOn` sorting function
* Add `System.Exit.die`
* Deprecate `versionTags` field of `Data.Version.Version`.
Add `makeVersion :: [Int] -> Version` constructor function to aid
migration to a future `versionTags`-less `Version`.
* Add `IsList Version` instance
* Weaken RealFloat constraints on some `Data.Complex` functions
* Add `Control.Monad.(<$!>)` as a strict version of `(<$>)`
* The `Data.Monoid` module now has the `PolyKinds` extension
enabled, so that the `Monoid` instance for `Proxy` are polykinded
like `Proxy` itself is.
* Make `abs` and `signum` handle (-0.0) correctly per IEEE-754.
* Re-export `Data.Word.Word` from `Prelude`
* Add `countLeadingZeros` and `countTrailingZeros` methods to
`Data.Bits.FiniteBits` class
* Add `Data.List.uncons` list destructor (#9550)
* Export `Monoid(..)` from `Prelude`
* Export `Foldable(..)` from `Prelude`
(hiding `fold`, `foldl'`, `foldr'`, and `toList`)
* Export `Traversable(..)` from `Prelude`
* Set fixity for `Data.Foldable.{elem,notElem}` to match the
conventional one set for `Data.List.{elem,notElem}` (#9610)
* Turn `toList`, `elem`, `sum`, `product`, `maximum`, and `minimum`
into `Foldable` methods (#9621)
* Replace the `Data.List`-exported functions
```
all, and, any, concat, concatMap, elem, find, product, sum,
mapAccumL, mapAccumR
```
by re-exports of their generalised `Data.Foldable`/`Data.Traversable`
counterparts. In other words, unqualified imports of `Data.List`
and `Data.Foldable`/`Data.Traversable` no longer lead to conflicting
definitions. (#9586)
* New (unofficial) module `GHC.OldList` containing only list-specialised
versions of the functions from `Data.List` (in other words, `GHC.OldList`
corresponds to `base-4.7.0.2`'s `Data.List`)
* Replace the `Control.Monad`-exported functions
```
sequence_, msum, mapM_, forM_,
forM, mapM, sequence
```
by re-exports of their generalised `Data.Foldable`/`Data.Traversable`
counterparts. In other words, unqualified imports of `Control.Monad`
and `Data.Foldable`/`Data.Traversable` no longer lead to conflicting
definitions. (#9586)
* Generalise `Control.Monad.{when,unless,guard}` from `Monad` to
`Applicative` and from `MonadPlus` to `Alternative` respectively.
* Generalise `Control.Monad.{foldM,foldM_}` to `Foldable`
* `scanr`, `mapAccumL` and `filterM` now take part in list fusion (#9355,
#9502, #9546)
* Remove deprecated `Data.OldTypeable` (#9639)
* New module `Data.Bifunctor` providing the `Bifunctor(bimap,first,second)`
class (previously defined in `bifunctors` package) (#9682)
* New module `Data.Void` providing the canonical uninhabited type `Void`
(previously defined in `void` package) (#9814)
* Update Unicode class definitions to Unicode version 7.0
* Add `Alt`, an `Alternative` wrapper, to `Data.Monoid`. (#9759)
* Add `isSubsequenceOf` to `Data.List` (#9767)
* The arguments to `==` and `eq` in `Data.List.nub` and `Data.List.nubBy`
are swapped, such that `Data.List.nubBy (<) [1,2]` now returns `[1]`
instead of `[1,2]` (#2528, #3280, #7913)
* New module `Data.Functor.Identity` (previously provided by `transformers`
package). (#9664)
* Add `scanl'`, a strictly accumulating version of `scanl`, to `Data.List`
and `Data.OldList`. (#9368)
* Add `fillBytes` to `Foreign.Marshal.Utils`.
* Add new `displayException` method to `Exception` typeclass. (#9822)
* Add `Data.Bits.toIntegralSized`, a size-checked version of
`fromIntegral`. (#9816)
* New module `Numeric.Natural` providing new `Natural` type
representing non-negative arbitrary-precision integers. The `GHC.Natural`
module exposes additional GHC-specific primitives. (#9818)
* Add `(Storable a, Integeral a) => Storable (Ratio a)` instance (#9826)
* Add `Storable a => Storable (Complex a)` instance (#9826)
* New module `GHC.RTS.Flags` that provides accessors to runtime flags.
* Expose functions for per-thread allocation counters and limits in `GHC.Conc`
disableAllocationLimit :: IO ()
enableAllocationLimit :: IO ()
getAllocationCounter :: IO Int64
setAllocationCounter :: Int64 -> IO ()
together with a new exception `AllocationLimitExceeded`.
* Make `read . show = id` for `Data.Fixed` (#9240)
* Add `calloc` and `callocBytes` to `Foreign.Marshal.Alloc`. (#9859)
* Add `callocArray` and `callocArray0` to `Foreign.Marshal.Array`. (#9859)
* Restore invariant in `Data (Ratio a)` instance (#10011)
* Add/expose `rnfTypeRep`, `rnfTyCon`, `typeRepFingerprint`, and
`tyConFingerprint` helpers to `Data.Typeable`.
* Define proper `MINIMAL` pragma for `class Ix`. (#10142)
## 4.7.0.2 *Dec 2014*
* Bundled with GHC 7.8.4
* Fix performance bug in `Data.List.inits` (#9345)
* Fix handling of null bytes in `Debug.Trace.trace` (#9395)
## 4.7.0.1 *Jul 2014*
* Bundled with GHC 7.8.3
* Unhide `Foreign.ForeignPtr` in Haddock (#8475)
* Fix recomputation of `TypeRep` in `Typeable` type-application instance
(#9203)
* Fix regression in Data.Fixed Read instance (#9231)
* Fix `fdReady` to honor `FD_SETSIZE` (#9168)
## 4.7.0.0 *Apr 2014*
* Bundled with GHC 7.8.1
* Add `/Since: 4.[4567].0.0/` Haddock annotations to entities
denoting the package version, when the given entity was introduced
(or its type signature changed in a non-compatible way)
* The `Control.Category` module now has the `PolyKinds` extension
enabled, meaning that instances of `Category` no longer need be of
kind `* -> * -> *`.
* There are now `Foldable` and `Traversable` instances for `Either a`,
`Const r`, and `(,) a`.
* There are now `Show`, `Read`, `Eq`, `Ord`, `Monoid`, `Generic`, and
`Generic1` instances for `Const`.
* There is now a `Data` instance for `Data.Version`.
* A new `Data.Bits.FiniteBits` class has been added to represent
types with fixed bit-count. The existing `Bits` class is extended
with a `bitSizeMaybe` method to replace the now obsolete
`bitsize` method.
* `Data.Bits.Bits` gained a new `zeroBits` method which completes the
`Bits` API with a direct way to introduce a value with all bits cleared.
* There are now `Bits` and `FiniteBits` instances for `Bool`.
* There are now `Eq`, `Ord`, `Show`, `Read`, `Generic`. and `Generic1`
instances for `ZipList`.
* There are now `Eq`, `Ord`, `Show` and `Read` instances for `Down`.
* There are now `Eq`, `Ord`, `Show`, `Read` and `Generic` instances
for types in GHC.Generics (`U1`, `Par1`, `Rec1`, `K1`, `M1`,
`(:+:)`, `(:*:)`, `(:.:)`).
* `Data.Monoid`: There are now `Generic` instances for `Dual`, `Endo`,
`All`, `Any`, `Sum`, `Product`, `First`, and `Last`; as well as
`Generic1` instances for `Dual`, `Sum`, `Product`, `First`, and `Last`.
* The `Data.Monoid.{Product,Sum}` newtype wrappers now have `Num` instances.
* There are now `Functor` instances for `System.Console.GetOpt`'s
`ArgOrder`, `OptDescr`, and `ArgDescr`.
* A zero-width unboxed poly-kinded `Proxy#` was added to
`GHC.Prim`. It can be used to make it so that there is no the
operational overhead for passing around proxy arguments to model
type application.
* New `Data.Proxy` module providing a concrete, poly-kinded proxy type.
* New `Data.Coerce` module which exports the new `Coercible` class
together with the `coerce` primitive which provide safe coercion
(wrt role checking) between types with same representation.
* `Control.Concurrent.MVar` has a new implementation of `readMVar`,
which fixes a long-standing bug where `readMVar` is only atomic if
there are no other threads running `putMVar`. `readMVar` now is
atomic, and is guaranteed to return the value from the first
`putMVar`. There is also a new `tryReadMVar` which is a
non-blocking version.
* New `Control.Concurrent.MVar.withMVarMasked` which executes
`IO` action with asynchronous exceptions masked in the same style
as the existing `modifyMVarMasked` and `modifyMVarMasked_`.
* New `threadWait{Read,Write}STM :: Fd -> IO (STM (), IO ())`
functions added to `Control.Concurrent` for waiting on FD
readiness with STM actions.
* Expose `Data.Fixed.Fixed`'s constructor.
* There are now byte endian-swapping primitives
`byteSwap{16,32,64}` available in `Data.Word`, which use
optimized machine instructions when available.
* `Data.Bool` now exports `bool :: a -> a -> Bool -> a`, analogously
to `maybe` and `either` in their respective modules.
* `Data.Either` now exports `isLeft, isRight :: Either a b -> Bool`.
* `Debug.Trace` now exports `traceId`, `traceShowId`, `traceM`,
and `traceShowM`.
* `Data.Functor` now exports `($>)` and `void`.
* Rewrote portions of `Text.Printf`, and made changes to `Numeric`
(added `Numeric.showFFloatAlt` and `Numeric.showGFloatAlt`) and
`GHC.Float` (added `formatRealFloatAlt`) to support it. The
rewritten version is extensible to user types, adds a "generic"
format specifier "`%v`", extends the `printf` spec to support much
of C's `printf(3)` functionality, and fixes the spurious warnings
about using `Text.Printf.printf` at `(IO a)` while ignoring the
return value. These changes were contributed by Bart Massey.
* The minimal complete definitions for all type-classes with cyclic
default implementations have been explicitly annotated with the
new `{-# MINIMAL #-}` pragma.
* `Control.Applicative.WrappedMonad`, which can be used to convert a
`Monad` to an `Applicative`, has now a
`Monad m => Monad (WrappedMonad m)` instance.
* There is now a `Generic` and a `Generic1` instance for `WrappedMonad`
and `WrappedArrow`.
* Handle `ExitFailure (-sig)` on Unix by killing process with signal `sig`.
* New module `Data.Type.Bool` providing operations on type-level booleans.
* Expose `System.Mem.performMinorGC` for triggering minor GCs.
* New `System.Environment.{set,unset}Env` for manipulating
environment variables.
* Add `Typeable` instance for `(->)` and `RealWorld`.
* Declare CPP header `` officially obsolete as GHC 7.8+
does not support hand-written `Typeable` instances anymore.
* Remove (unmaintained) Hugs98 and NHC98 specific code.
* Optimize `System.Timeout.timeout` for the threaded RTS.
* Remove deprecated functions `unsafeInterleaveST`, `unsafeIOToST`,
and `unsafeSTToIO` from `Control.Monad.ST`.
* Add a new superclass `SomeAsyncException` for all asynchronous exceptions
and makes the existing `AsyncException` and `Timeout` exception children
of `SomeAsyncException` in the hierarchy.
* Remove deprecated functions `blocked`, `unblock`, and `block` from
`Control.Exception`.
* Remove deprecated function `forkIOUnmasked` from `Control.Concurrent`.
* Remove deprecated function `unsafePerformIO` export from `Foreign`
(still available via `System.IO.Unsafe.unsafePerformIO`).
* Various fixes and other improvements (see Git history for full details).