base 4.18.0.0 → 4.18.1.0
raw patch · 8 files changed
+105/−9 lines, 8 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Control.Arrow: infixr 2 |||
+ Control.Arrow: infixr 2 +++
- Control.Monad.Instances: infixl 1 >>=
+ Control.Monad.Instances: infixl 1 >>
- GHC.Base: infixl 1 >>=
+ GHC.Base: infixl 1 >>
- Prelude: infixl 6 -
+ Prelude: infixl 6 +
Files
- Data/Foldable1.hs +58/−1
- Debug/Trace.hs +3/−3
- GHC/Float.hs +19/−0
- Numeric.hs +8/−0
- System/Posix/Internals.hs +1/−1
- base.cabal +3/−2
- changelog.md +12/−1
- include/HsBase.h +1/−1
Data/Foldable1.hs view
@@ -2,6 +2,9 @@ -- Copyright: Edward Kmett, Oleg Grenrus -- License: BSD-3-Clause --+-- A class of non-empty data structures that can be folded to a summary value.+--+-- @since 4.18.0.0 {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}@@ -12,7 +15,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE TypeOperators #-} --- | A class of non-empty data structures that can be folded to a summary value. module Data.Foldable1 ( Foldable1(..), foldr1, foldr1',@@ -65,6 +67,8 @@ ------------------------------------------------------------------------------- -- | Non-empty data structures that can be folded.+--+-- @since 4.18.0.0 class Foldable t => Foldable1 t where {-# MINIMAL foldMap1 | foldrMap1 #-} @@ -83,6 +87,7 @@ -- foldrMap1 f g = foldrMap1 f g . toNonEmpty -- | Combine the elements of a structure using a semigroup.+ -- @since 4.18.0.0 fold1 :: Semigroup m => t m -> m fold1 = foldMap1 id @@ -92,6 +97,7 @@ -- >>> foldMap1 Sum (1 :| [2, 3, 4]) -- Sum {getSum = 10} --+ -- @since 4.18.0.0 foldMap1 :: Semigroup m => (a -> m) -> t a -> m foldMap1 f = foldrMap1 f (\a m -> f a <> m) @@ -100,6 +106,7 @@ -- >>> foldMap1' Sum (1 :| [2, 3, 4]) -- Sum {getSum = 10} --+ -- @since 4.18.0.0 foldMap1' :: Semigroup m => (a -> m) -> t a -> m foldMap1' f = foldlMap1' f (\m a -> m <> f a) @@ -108,6 +115,7 @@ -- >>> toNonEmpty (Identity 2) -- 2 :| [] --+ -- @since 4.18.0.0 toNonEmpty :: t a -> NonEmpty a toNonEmpty = runNonEmptyDList . foldMap1 singleton @@ -116,6 +124,7 @@ -- >>> maximum (32 :| [64, 8, 128, 16]) -- 128 --+ -- @since 4.18.0.0 maximum :: Ord a => t a -> a maximum = getMax #. foldMap1' Max @@ -124,6 +133,7 @@ -- >>> minimum (32 :| [64, 8, 128, 16]) -- 8 --+ -- @since 4.18.0.0 minimum :: Ord a => t a -> a minimum = getMin #. foldMap1' Min @@ -132,6 +142,7 @@ -- >>> head (1 :| [2, 3, 4]) -- 1 --+ -- @since 4.18.0.0 head :: t a -> a head = getFirst #. foldMap1 First @@ -140,10 +151,12 @@ -- >>> last (1 :| [2, 3, 4]) -- 4 --+ -- @since 4.18.0.0 last :: t a -> a last = getLast #. foldMap1 Last -- | Generalized 'foldr1'.+ -- @since 4.18.0.0 foldrMap1 :: (a -> b) -> (a -> b -> b) -> t a -> b foldrMap1 f g xs = appFromMaybe (foldMap1 (FromMaybe #. h) xs) Nothing@@ -152,6 +165,7 @@ h a (Just b) = g a b -- | Generalized 'foldl1''.+ -- @since 4.18.0.0 foldlMap1' :: (a -> b) -> (b -> a -> b) -> t a -> b foldlMap1' f g xs = foldrMap1 f' g' xs SNothing@@ -165,6 +179,7 @@ g' a x (SJust b) = x $! SJust (g b a) -- | Generalized 'foldl1'.+ -- @since 4.18.0.0 foldlMap1 :: (a -> b) -> (b -> a -> b) -> t a -> b foldlMap1 f g xs = appFromMaybe (getDual (foldMap1 ((Dual . FromMaybe) #. h) xs)) Nothing@@ -173,6 +188,7 @@ h a (Just b) = g b a -- | Generalized 'foldr1''.+ -- @since 4.18.0.0 foldrMap1' :: (a -> b) -> (a -> b -> b) -> t a -> b foldrMap1' f g xs = foldlMap1 f' g' xs SNothing@@ -204,6 +220,7 @@ -- -- @foldr1 f = foldr1 f . 'toNonEmpty'@ --+-- @since 4.18.0.0 foldr1 :: Foldable1 t => (a -> a -> a) -> t a -> a foldr1 = foldrMap1 id {-# INLINE foldr1 #-}@@ -211,6 +228,7 @@ -- | Right-associative fold of a structure, but with strict application of -- the operator. --+-- @since 4.18.0.0 foldr1' :: Foldable1 t => (a -> a -> a) -> t a -> a foldr1' = foldrMap1' id {-# INLINE foldr1' #-}@@ -239,6 +257,7 @@ -- -- @foldl1 f z = foldl1 f . 'toNonEmpty'@ --+-- @since 4.18.0.0 foldl1 :: Foldable1 t => (a -> a -> a) -> t a -> a foldl1 = foldlMap1 id {-# INLINE foldl1 #-}@@ -256,6 +275,7 @@ -- -- @foldl1' f z = foldl1 f . 'toNonEmpty'@ --+-- @since 4.18.0.0 foldl1' :: Foldable1 t => (a -> a -> a) -> t a -> a foldl1' = foldlMap1' id {-# INLINE foldl1' #-}@@ -271,6 +291,7 @@ -- >>> intercalate1 mempty $ "I" :| ["Am", "Fine", "You?"] -- "IAmFineYou?" --+-- @since 4.18.0.0 intercalate1 :: (Foldable1 t, Semigroup m) => m -> t m -> m intercalate1 = flip intercalateMap1 id @@ -279,10 +300,14 @@ -- | Monadic fold over the elements of a non-empty structure, -- associating to the right, i.e. from right to left.+--+-- @since 4.18.0.0 foldrM1 :: (Foldable1 t, Monad m) => (a -> a -> m a) -> t a -> m a foldrM1 = foldrMapM1 return -- | Map variant of 'foldrM1'.+--+-- @since 4.18.0.0 foldrMapM1 :: (Foldable1 t, Monad m) => (a -> m b) -> (a -> b -> m b) -> t a -> m b foldrMapM1 g f = go . toNonEmpty where@@ -293,16 +318,22 @@ -- | Monadic fold over the elements of a non-empty structure, -- associating to the left, i.e. from left to right.+--+-- @since 4.18.0.0 foldlM1 :: (Foldable1 t, Monad m) => (a -> a -> m a) -> t a -> m a foldlM1 = foldlMapM1 return -- | Map variant of 'foldlM1'.+--+-- @since 4.18.0.0 foldlMapM1 :: (Foldable1 t, Monad m) => (a -> m b) -> (b -> a -> m b) -> t a -> m b foldlMapM1 g f t = g x >>= \y -> foldlM f y xs where x:|xs = toNonEmpty t -- | The largest element of a non-empty structure with respect to the -- given comparison function.+--+-- @since 4.18.0.0 maximumBy :: Foldable1 t => (a -> a -> Ordering) -> t a -> a maximumBy cmp = foldl1' max' where max' x y = case cmp x y of@@ -311,6 +342,8 @@ -- | The least element of a non-empty structure with respect to the -- given comparison function.+--+-- @since 4.18.0.0 minimumBy :: Foldable1 t => (a -> a -> Ordering) -> t a -> a minimumBy cmp = foldl1' min' where min' x y = case cmp x y of@@ -356,6 +389,7 @@ -- Instances for misc base types ------------------------------------------------------------------------------- +-- | @since 4.18.0.0 instance Foldable1 NonEmpty where foldMap1 f (x :| xs) = go (f x) xs where go y [] = y@@ -375,9 +409,11 @@ head = NE.head last = NE.last +-- | @since 4.18.0.0 instance Foldable1 Down where foldMap1 = coerce +-- | @since 4.18.0.0 instance Foldable1 Complex where foldMap1 f (x :+ y) = f x <> f y @@ -389,6 +425,7 @@ -- 3+ tuples are not Foldable/Traversable +-- | @since 4.18.0.0 instance Foldable1 Solo where foldMap1 f (MkSolo y) = f y toNonEmpty (MkSolo x) = x :| []@@ -397,6 +434,7 @@ head (MkSolo x) = x last (MkSolo x) = x +-- | @since 4.18.0.0 instance Foldable1 ((,) a) where foldMap1 f (_, y) = f y toNonEmpty (_, x) = x :| []@@ -409,52 +447,68 @@ -- Monoid / Semigroup instances ------------------------------------------------------------------------------- +-- | @since 4.18.0.0 instance Foldable1 Dual where foldMap1 = coerce +-- | @since 4.18.0.0 instance Foldable1 Sum where foldMap1 = coerce +-- | @since 4.18.0.0 instance Foldable1 Product where foldMap1 = coerce +-- | @since 4.18.0.0 instance Foldable1 Min where foldMap1 = coerce +-- | @since 4.18.0.0 instance Foldable1 Max where foldMap1 = coerce +-- | @since 4.18.0.0 instance Foldable1 First where foldMap1 = coerce +-- | @since 4.18.0.0 instance Foldable1 Last where foldMap1 = coerce +-- | @since 4.18.0.0 deriving instance (Foldable1 f) => Foldable1 (Mon.Alt f) +-- | @since 4.18.0.0 deriving instance (Foldable1 f) => Foldable1 (Mon.Ap f) ------------------------------------------------------------------------------- -- GHC.Generics instances ------------------------------------------------------------------------------- +-- | @since 4.18.0.0 instance Foldable1 V1 where foldMap1 _ x = x `seq` error "foldMap1 @V1" +-- | @since 4.18.0.0 instance Foldable1 Par1 where foldMap1 = coerce +-- | @since 4.18.0.0 deriving instance Foldable1 f => Foldable1 (Rec1 f) +-- | @since 4.18.0.0 deriving instance Foldable1 f => Foldable1 (M1 i c f) +-- | @since 4.18.0.0 instance (Foldable1 f, Foldable1 g) => Foldable1 (f :+: g) where foldMap1 f (L1 x) = foldMap1 f x foldMap1 f (R1 y) = foldMap1 f y +-- | @since 4.18.0.0 instance (Foldable1 f, Foldable1 g) => Foldable1 (f :*: g) where foldMap1 f (x :*: y) = foldMap1 f x <> foldMap1 f y +-- | @since 4.18.0.0 instance (Foldable1 f, Foldable1 g) => Foldable1 (f :.: g) where foldMap1 f = foldMap1 (foldMap1 f) . unComp1 @@ -462,6 +516,7 @@ -- Extra instances ------------------------------------------------------------------------------- +-- | @since 4.18.0.0 instance Foldable1 Identity where foldMap1 = coerce @@ -486,6 +541,7 @@ head (Functor.Pair x _) = head x last (Functor.Pair _ y) = last y +-- | @since 4.18.0.0 instance (Foldable1 f, Foldable1 g) => Foldable1 (Functor.Sum f g) where foldMap1 f (Functor.InL x) = foldMap1 f x foldMap1 f (Functor.InR y) = foldMap1 f y@@ -506,6 +562,7 @@ maximum (Functor.InL x) = maximum x maximum (Functor.InR y) = maximum y +-- | @since 4.18.0.0 instance (Foldable1 f, Foldable1 g) => Foldable1 (Compose f g) where foldMap1 f = foldMap1 (foldMap1 f) . getCompose
Debug/Trace.hs view
@@ -173,7 +173,7 @@ hello ("hello","world") -@since 4.17.0.0+@since 4.18.0.0 -} traceWith :: (a -> String) -> a -> a traceWith f a = trace (f a) a@@ -186,7 +186,7 @@ 3 [1,2,3] -@since 4.17.0.0+@since 4.18.0.0 -} traceShowWith :: Show b => (a -> b) -> a -> a traceShowWith f = traceWith (show . f)@@ -303,7 +303,7 @@ -- | Like 'traceEvent', but emits the result of calling a function on its -- argument. ----- @since 4.17.0.0+-- @since 4.18.0.0 traceEventWith :: (a -> String) -> a -> a traceEventWith f a = traceEvent (f a) a
GHC/Float.hs view
@@ -1640,3 +1640,22 @@ "Word# -> Natural -> Double#" forall x. naturalToDouble# (NS x) = word2Double# x #-}++-- We don't have word64ToFloat/word64ToDouble primops (#23908), only+-- word2Float/word2Double, so we can only perform these transformations when+-- word-size is 64-bit.+#if WORD_SIZE_IN_BITS == 64+{-# RULES++"Int64# -> Integer -> Float#"+ forall x. integerToFloat# (integerFromInt64# x) = int2Float# (int64ToInt# x)++"Int64# -> Integer -> Double#"+ forall x. integerToDouble# (integerFromInt64# x) = int2Double# (int64ToInt# x)++"Word64# -> Integer -> Float#"+ forall x. integerToFloat# (integerFromWord64# x) = word2Float# (word64ToWord# x)++"Word64# -> Integer -> Double#"+ forall x. integerToDouble# (integerFromWord64# x) = word2Double# (word64ToWord# x) #-}+#endif
Numeric.hs view
@@ -117,6 +117,14 @@ -- | Reads an /unsigned/ 'RealFrac' value, -- expressed in decimal scientific notation.+--+-- Note that this function takes time linear in the magnitude of its input+-- which can scale exponentially with input size (e.g. @"1e100000000"@ is a+-- very large number while having a very small textual form).+-- For this reason, users should take care to avoid using this function on+-- untrusted input. Users needing to parse floating point values+-- (e.g. 'Float') are encouraged to instead use 'read', which does+-- not suffer from this issue. readFloat :: RealFrac a => ReadS a readFloat = readP_to_S readFloatP
System/Posix/Internals.hs view
@@ -499,7 +499,7 @@ c_ftruncate :: CInt -> FileOffset -> IO CInt foreign import javascript interruptible "(($1_1,$1_2,$c) => { return h$base_unlink($1_1,$1_2,$c); })" c_unlink :: CString -> IO CInt-foreign import javascript unsafe "(() => { return h$base_getpid; })"+foreign import javascript unsafe "h$base_getpid" c_getpid :: IO CPid -- foreign import ccall unsafe "HsBase.h fork" -- c_fork :: IO CPid
base.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: base-version: 4.18.0.0+version: 4.18.1.0 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause@@ -397,6 +397,7 @@ if os(windows) -- Windows requires some extra libraries for linking because the RTS -- is no longer re-exporting them.+ -- mingwex: provides GNU POSIX extensions that aren't provided by ucrt. -- mingw32: Unfortunately required because of a resource leak between -- mingwex and mingw32. the __math_err symbol is defined in -- mingw32 which is required by mingwex.@@ -409,7 +410,7 @@ -- advapi32: provides advanced kernel functions extra-libraries: wsock32, user32, shell32, mingw32, kernel32, advapi32,- ws2_32, shlwapi, ole32, rpcrt4, ntdll+ mingwex, ws2_32, shlwapi, ole32, rpcrt4, ntdll -- Minimum supported Windows version. -- These numbers can be found at: -- https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx
changelog.md view
@@ -1,7 +1,15 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) -## 4.18.0.0 *TBA*+## 4.18.1.0 *September 2023* + * Add missing int64/word64-to-double/float rules ([CLC Proposal #203](https://github.com/haskell/core-libraries-committee/issues/203))++ * Restore `mingwex` dependency on Windows (#23309).++ * Fix an incorrect CPP guard on `darwin_HOST_OS`.++## 4.18.0.0 *March 2023*+ * Add `INLINABLE` pragmas to `generic*` functions in Data.OldList ([CLC proposal #129](https://github.com/haskell/core-libraries-committee/issues/130)) * `Foreign.C.ConstPtr.ConstrPtr` was added to encode `const`-qualified pointer types in foreign declarations when using `CApiFFI` extension. ([CLC proposal #117](https://github.com/haskell/core-libraries-committee/issues/117))@@ -71,6 +79,9 @@ * `InfoProv` now has additional `ipSrcFile` and `ipSrcSpan` fields. `ipLoc` is now a function computed from these fields. * The `whereFrom` function has been moved+ * Add functions `traceWith`, `traceShowWith`, `traceEventWith` to+ `Debug.Trace`, per+ [CLC proposal #36](https://github.com/haskell/core-libraries-committee/issues/36). * Refactor `generalCategory` to stop very large literal string being inlined to call-sites. ([CLC proposal #130](https://github.com/haskell/core-libraries-committee/issues/130)) * Add INLINABLE pragmas to `generic*` functions in Data.OldList ([CLC proposal #129](https://github.com/haskell/core-libraries-committee/issues/130))
include/HsBase.h view
@@ -540,7 +540,7 @@ } #endif -#if darwin_HOST_OS+#if defined(darwin_HOST_OS) // You should not access _environ directly on Darwin in a bundle/shared library. // See #2458 and http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man7/environ.7.html #include <crt_externs.h>