Teo Camarasu pushed to branch wip/T26865 at Glasgow Haskell Compiler / GHC
Commits:
-
905e07ec
by Teo Camarasu at 2026-01-31T13:57:07+00:00
19 changed files:
- libraries/base/src/Data/Bool.hs
- libraries/base/src/Data/List.hs
- libraries/base/src/Data/List/NubOrdSet.hs
- libraries/ghc-internal/ghc-internal.cabal.in
- − libraries/ghc-internal/src/GHC/Internal/Data/Bool.hs
- libraries/ghc-internal/src/GHC/Internal/Data/Foldable.hs
- libraries/ghc-internal/src/GHC/Internal/Data/Function.hs
- libraries/ghc-internal/src/GHC/Internal/Data/Type/Bool.hs
- libraries/ghc-internal/src/GHC/Internal/Data/Type/Ord.hs
- libraries/ghc-internal/src/GHC/Internal/Data/Version.hs
- libraries/ghc-internal/src/GHC/Internal/IO/FD.hs
- libraries/ghc-internal/src/GHC/Internal/JS/Prim.hs
- libraries/ghc-internal/src/GHC/Internal/System/IO/OS.hs
- libraries/ghc-internal/src/GHC/Internal/TH/Lift.hs
- libraries/ghc-internal/src/GHC/Internal/TypeError.hs
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/base-exports.stdout-ws-32
Changes:
| 1 | -{-# LANGUAGE Safe #-}
|
|
| 1 | +{-# LANGUAGE Trustworthy #-}
|
|
| 2 | 2 | |
| 3 | 3 | -- |
|
| 4 | 4 | --
|
| ... | ... | @@ -24,4 +24,39 @@ module Data.Bool |
| 24 | 24 | bool
|
| 25 | 25 | ) where
|
| 26 | 26 | |
| 27 | -import GHC.Internal.Data.Bool |
|
| \ No newline at end of file | ||
| 27 | +import GHC.Internal.Base
|
|
| 28 | + |
|
| 29 | +-- $setup
|
|
| 30 | +-- >>> import Prelude
|
|
| 31 | + |
|
| 32 | +-- | Case analysis for the 'Bool' type. @'bool' f t p@ evaluates to @f@
|
|
| 33 | +-- when @p@ is 'False', and evaluates to @t@ when @p@ is 'True'.
|
|
| 34 | +--
|
|
| 35 | +-- This is equivalent to @if p then t else f@; that is, one can
|
|
| 36 | +-- think of it as an if-then-else construct with its arguments
|
|
| 37 | +-- reordered.
|
|
| 38 | +--
|
|
| 39 | +-- @since base-4.7.0.0
|
|
| 40 | +--
|
|
| 41 | +-- ==== __Examples__
|
|
| 42 | +--
|
|
| 43 | +-- Basic usage:
|
|
| 44 | +--
|
|
| 45 | +-- >>> bool "foo" "bar" True
|
|
| 46 | +-- "bar"
|
|
| 47 | +-- >>> bool "foo" "bar" False
|
|
| 48 | +-- "foo"
|
|
| 49 | +--
|
|
| 50 | +-- Confirm that @'bool' f t p@ and @if p then t else f@ are
|
|
| 51 | +-- equivalent:
|
|
| 52 | +--
|
|
| 53 | +-- >>> let p = True; f = "bar"; t = "foo"
|
|
| 54 | +-- >>> bool f t p == if p then t else f
|
|
| 55 | +-- True
|
|
| 56 | +-- >>> let p = False
|
|
| 57 | +-- >>> bool f t p == if p then t else f
|
|
| 58 | +-- True
|
|
| 59 | +--
|
|
| 60 | +bool :: a -> a -> Bool -> a
|
|
| 61 | +bool f _ False = f
|
|
| 62 | +bool _ t True = t |
| 1 | -{-# LANGUAGE Safe #-}
|
|
| 1 | +{-# LANGUAGE Trustworthy #-}
|
|
| 2 | 2 | |
| 3 | 3 | -- |
|
| 4 | 4 | --
|
| ... | ... | @@ -184,7 +184,7 @@ module Data.List |
| 184 | 184 | genericReplicate
|
| 185 | 185 | ) where
|
| 186 | 186 | |
| 187 | -import GHC.Internal.Data.Bool (otherwise)
|
|
| 187 | +import GHC.Internal.Base (otherwise)
|
|
| 188 | 188 | import GHC.Internal.Data.Function (const)
|
| 189 | 189 | import GHC.Internal.Data.List
|
| 190 | 190 | import GHC.Internal.Data.List.NonEmpty (NonEmpty(..))
|
| ... | ... | @@ -11,7 +11,7 @@ module Data.List.NubOrdSet ( |
| 11 | 11 | insert,
|
| 12 | 12 | ) where
|
| 13 | 13 | |
| 14 | -import GHC.Internal.Data.Bool (Bool(..))
|
|
| 14 | +import GHC.Internal.Base (Bool(..))
|
|
| 15 | 15 | import GHC.Internal.Data.Function ((.))
|
| 16 | 16 | import GHC.Internal.Data.Ord (Ordering(..))
|
| 17 | 17 |
| ... | ... | @@ -140,7 +140,6 @@ Library |
| 140 | 140 | GHC.Internal.Control.Monad.ST.Imp
|
| 141 | 141 | GHC.Internal.Control.Monad.ST.Lazy.Imp
|
| 142 | 142 | GHC.Internal.Data.Bits
|
| 143 | - GHC.Internal.Data.Bool
|
|
| 144 | 143 | GHC.Internal.Data.Coerce
|
| 145 | 144 | GHC.Internal.Data.Data
|
| 146 | 145 | GHC.Internal.Data.Dynamic
|
| 1 | -{-# LANGUAGE Trustworthy #-}
|
|
| 2 | -{-# LANGUAGE NoImplicitPrelude #-}
|
|
| 3 | - |
|
| 4 | ------------------------------------------------------------------------------
|
|
| 5 | --- |
|
|
| 6 | --- Module : GHC.Internal.Data.Bool
|
|
| 7 | --- Copyright : (c) The University of Glasgow 2001
|
|
| 8 | --- License : BSD-style (see the file libraries/base/LICENSE)
|
|
| 9 | ---
|
|
| 10 | --- Maintainer : libraries@haskell.org
|
|
| 11 | --- Stability : stable
|
|
| 12 | --- Portability : portable
|
|
| 13 | ---
|
|
| 14 | --- The 'Bool' type and related functions.
|
|
| 15 | ---
|
|
| 16 | ------------------------------------------------------------------------------
|
|
| 17 | - |
|
| 18 | -module GHC.Internal.Data.Bool (
|
|
| 19 | - -- * Booleans
|
|
| 20 | - Bool(..),
|
|
| 21 | - -- ** Operations
|
|
| 22 | - (&&),
|
|
| 23 | - (||),
|
|
| 24 | - not,
|
|
| 25 | - otherwise,
|
|
| 26 | - bool,
|
|
| 27 | - ) where
|
|
| 28 | - |
|
| 29 | -import GHC.Internal.Base
|
|
| 30 | - |
|
| 31 | --- $setup
|
|
| 32 | --- >>> import Prelude
|
|
| 33 | - |
|
| 34 | --- | Case analysis for the 'Bool' type. @'bool' f t p@ evaluates to @f@
|
|
| 35 | --- when @p@ is 'False', and evaluates to @t@ when @p@ is 'True'.
|
|
| 36 | ---
|
|
| 37 | --- This is equivalent to @if p then t else f@; that is, one can
|
|
| 38 | --- think of it as an if-then-else construct with its arguments
|
|
| 39 | --- reordered.
|
|
| 40 | ---
|
|
| 41 | --- @since base-4.7.0.0
|
|
| 42 | ---
|
|
| 43 | --- ==== __Examples__
|
|
| 44 | ---
|
|
| 45 | --- Basic usage:
|
|
| 46 | ---
|
|
| 47 | --- >>> bool "foo" "bar" True
|
|
| 48 | --- "bar"
|
|
| 49 | --- >>> bool "foo" "bar" False
|
|
| 50 | --- "foo"
|
|
| 51 | ---
|
|
| 52 | --- Confirm that @'bool' f t p@ and @if p then t else f@ are
|
|
| 53 | --- equivalent:
|
|
| 54 | ---
|
|
| 55 | --- >>> let p = True; f = "bar"; t = "foo"
|
|
| 56 | --- >>> bool f t p == if p then t else f
|
|
| 57 | --- True
|
|
| 58 | --- >>> let p = False
|
|
| 59 | --- >>> bool f t p == if p then t else f
|
|
| 60 | --- True
|
|
| 61 | ---
|
|
| 62 | -bool :: a -> a -> Bool -> a
|
|
| 63 | -bool f _ False = f
|
|
| 64 | -bool _ t True = t |
| ... | ... | @@ -50,7 +50,6 @@ module GHC.Internal.Data.Foldable ( |
| 50 | 50 | find
|
| 51 | 51 | ) where
|
| 52 | 52 | |
| 53 | -import GHC.Internal.Data.Bool
|
|
| 54 | 53 | import GHC.Internal.Data.Either
|
| 55 | 54 | import GHC.Internal.Data.Eq
|
| 56 | 55 | import GHC.Internal.Data.Functor.Utils (Max(..), Min(..), (#.))
|
| ... | ... | @@ -30,8 +30,7 @@ module GHC.Internal.Data.Function |
| 30 | 30 | , applyWhen
|
| 31 | 31 | ) where
|
| 32 | 32 | |
| 33 | -import GHC.Internal.Base ( TYPE, ($), (.), id, const, flip )
|
|
| 34 | -import GHC.Internal.Data.Bool ( Bool(..) )
|
|
| 33 | +import GHC.Internal.Base ( TYPE, Bool(..), ($), (.), id, const, flip )
|
|
| 35 | 34 | |
| 36 | 35 | infixl 0 `on`
|
| 37 | 36 | infixl 1 &
|
| ... | ... | @@ -171,7 +170,7 @@ x & f = f x |
| 171 | 170 | -- | 'applyWhen' applies a function to a value if a condition is true,
|
| 172 | 171 | -- otherwise, it returns the value unchanged.
|
| 173 | 172 | --
|
| 174 | --- It is equivalent to @'flip' ('GHC.Internal.Data.Bool.bool' 'id')@.
|
|
| 173 | +-- It is equivalent to @'flip' ('Data.Bool.bool' 'id')@.
|
|
| 175 | 174 | --
|
| 176 | 175 | -- ==== __Examples__
|
| 177 | 176 | --
|
| 1 | 1 | {-# LANGUAGE DataKinds #-}
|
| 2 | 2 | {-# LANGUAGE NoImplicitPrelude #-}
|
| 3 | 3 | {-# LANGUAGE PolyKinds #-}
|
| 4 | -{-# LANGUAGE Safe #-}
|
|
| 4 | +{-# LANGUAGE Trustworthy #-}
|
|
| 5 | 5 | {-# LANGUAGE TypeFamilyDependencies #-}
|
| 6 | 6 | {-# LANGUAGE TypeOperators #-}
|
| 7 | 7 | |
| ... | ... | @@ -23,7 +23,7 @@ module GHC.Internal.Data.Type.Bool ( |
| 23 | 23 | If, type (&&), type (||), Not
|
| 24 | 24 | ) where
|
| 25 | 25 | |
| 26 | -import GHC.Internal.Data.Bool
|
|
| 26 | +import GHC.Internal.Base
|
|
| 27 | 27 | |
| 28 | 28 | -- This needs to be in base because (&&) is used in Data.Type.Equality.
|
| 29 | 29 | -- The other functions do not need to be in base, but seemed to be appropriate
|
| ... | ... | @@ -34,14 +34,11 @@ module GHC.Internal.Data.Type.Ord ( |
| 34 | 34 | , OrdCond
|
| 35 | 35 | ) where
|
| 36 | 36 | |
| 37 | -import GHC.Internal.Show(Show(..))
|
|
| 37 | +import GHC.Internal.Base
|
|
| 38 | +import GHC.Internal.Show (Show(..))
|
|
| 38 | 39 | import GHC.Internal.TypeError
|
| 39 | 40 | import GHC.Internal.TypeLits.Internal
|
| 40 | 41 | import GHC.Internal.TypeNats.Internal
|
| 41 | -import GHC.Internal.Types (type (~), Char)
|
|
| 42 | -import GHC.Internal.Data.Bool
|
|
| 43 | -import GHC.Internal.Data.Eq
|
|
| 44 | -import GHC.Internal.Data.Ord
|
|
| 45 | 42 | |
| 46 | 43 | -- | 'Compare' branches on the kind of its arguments to either compare by
|
| 47 | 44 | -- 'Symbol' or 'Nat'.
|
| ... | ... | @@ -37,13 +37,12 @@ module GHC.Internal.Data.Version ( |
| 37 | 37 | ) where
|
| 38 | 38 | |
| 39 | 39 | import GHC.Internal.Data.Functor ( Functor(..) )
|
| 40 | -import GHC.Internal.Data.Bool ( (&&) )
|
|
| 41 | 40 | import GHC.Internal.Data.Eq
|
| 42 | 41 | import GHC.Internal.Int ( Int )
|
| 43 | 42 | import GHC.Internal.Data.List ( map, sort, concat, concatMap, intersperse, (++) )
|
| 44 | 43 | import GHC.Internal.Data.Ord
|
| 45 | 44 | import GHC.Internal.Data.String ( String )
|
| 46 | -import GHC.Internal.Base ( Applicative(..) )
|
|
| 45 | +import GHC.Internal.Base ( Applicative(..), (&&) )
|
|
| 47 | 46 | import GHC.Internal.Generics
|
| 48 | 47 | import GHC.Internal.Unicode ( isDigit, isAlphaNum )
|
| 49 | 48 | import GHC.Internal.Read
|
| ... | ... | @@ -49,7 +49,6 @@ import GHC.Internal.Conc.IO |
| 49 | 49 | import GHC.Internal.IO.Exception
|
| 50 | 50 | #if defined(mingw32_HOST_OS)
|
| 51 | 51 | import GHC.Internal.Windows
|
| 52 | -import GHC.Internal.Data.Bool
|
|
| 53 | 52 | import GHC.Internal.IO.SubSystem ((<!>))
|
| 54 | 53 | import GHC.Internal.Foreign.Storable
|
| 55 | 54 | #endif
|
| ... | ... | @@ -46,7 +46,6 @@ import qualified GHC.Internal.Exception as Ex |
| 46 | 46 | import qualified GHC.Internal.Exts as Exts
|
| 47 | 47 | import qualified GHC.Internal.CString as GHC
|
| 48 | 48 | import GHC.Internal.IO
|
| 49 | -import GHC.Internal.Data.Bool
|
|
| 50 | 49 | import GHC.Internal.Base
|
| 51 | 50 | import GHC.Internal.Show
|
| 52 | 51 |
| ... | ... | @@ -29,7 +29,7 @@ import GHC.Internal.Control.Exception (mask) |
| 29 | 29 | import GHC.Internal.Data.Function (const, (.), ($))
|
| 30 | 30 | import GHC.Internal.Data.Functor (fmap)
|
| 31 | 31 | #if defined(mingw32_HOST_OS)
|
| 32 | -import GHC.Internal.Data.Bool (otherwise)
|
|
| 32 | +import GHC.Internal.Base (otherwise)
|
|
| 33 | 33 | #endif
|
| 34 | 34 | import GHC.Internal.Data.Maybe (Maybe (Nothing), maybe)
|
| 35 | 35 | #if defined(mingw32_HOST_OS)
|
| ... | ... | @@ -34,7 +34,6 @@ import GHC.Internal.TH.Monad |
| 34 | 34 | import qualified GHC.Internal.TH.Lib as Lib (litE) -- See wrinkle (W4) of Note [Tracking dependencies on primitives]
|
| 35 | 35 | |
| 36 | 36 | import GHC.Internal.Data.Either
|
| 37 | -import GHC.Internal.Data.Bool
|
|
| 38 | 37 | import GHC.Internal.Base hiding (NonEmpty(..), Type, Module, inline)
|
| 39 | 38 | import GHC.Internal.Data.NonEmpty (NonEmpty(..))
|
| 40 | 39 | import GHC.Internal.Integer
|
| ... | ... | @@ -31,8 +31,7 @@ module GHC.Internal.TypeError |
| 31 | 31 | , Unsatisfiable, unsatisfiable
|
| 32 | 32 | ) where
|
| 33 | 33 | |
| 34 | -import GHC.Internal.Data.Bool
|
|
| 35 | -import GHC.Internal.Types (TYPE, Constraint, Symbol)
|
|
| 34 | +import GHC.Internal.Types (TYPE, Bool(True), Constraint, Symbol)
|
|
| 36 | 35 | |
| 37 | 36 | {- Note [Custom type errors]
|
| 38 | 37 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| ... | ... | @@ -746,7 +746,7 @@ module Data.Bits where |
| 746 | 746 | toIntegralSized :: forall a b. (GHC.Internal.Real.Integral a, GHC.Internal.Real.Integral b, Bits a, Bits b) => a -> GHC.Internal.Maybe.Maybe b
|
| 747 | 747 | |
| 748 | 748 | module Data.Bool where
|
| 749 | - -- Safety: Safe
|
|
| 749 | + -- Safety: Trustworthy
|
|
| 750 | 750 | (&&) :: Bool -> Bool -> Bool
|
| 751 | 751 | type Bool :: *
|
| 752 | 752 | data Bool = False | True
|
| ... | ... | @@ -1308,7 +1308,7 @@ module Data.Kind where |
| 1308 | 1308 | type Type = TYPE GHC.Internal.Types.LiftedRep
|
| 1309 | 1309 | |
| 1310 | 1310 | module Data.List where
|
| 1311 | - -- Safety: Safe
|
|
| 1311 | + -- Safety: Trustworthy
|
|
| 1312 | 1312 | (!!) :: forall a. GHC.Internal.Stack.Types.HasCallStack => [a] -> GHC.Internal.Types.Int -> a
|
| 1313 | 1313 | (!?) :: forall a. [a] -> GHC.Internal.Types.Int -> GHC.Internal.Maybe.Maybe a
|
| 1314 | 1314 | (++) :: forall a. [a] -> [a] -> [a]
|
| ... | ... | @@ -746,7 +746,7 @@ module Data.Bits where |
| 746 | 746 | toIntegralSized :: forall a b. (GHC.Internal.Real.Integral a, GHC.Internal.Real.Integral b, Bits a, Bits b) => a -> GHC.Internal.Maybe.Maybe b
|
| 747 | 747 | |
| 748 | 748 | module Data.Bool where
|
| 749 | - -- Safety: Safe
|
|
| 749 | + -- Safety: Trustworthy
|
|
| 750 | 750 | (&&) :: Bool -> Bool -> Bool
|
| 751 | 751 | type Bool :: *
|
| 752 | 752 | data Bool = False | True
|
| ... | ... | @@ -1308,7 +1308,7 @@ module Data.Kind where |
| 1308 | 1308 | type Type = TYPE GHC.Internal.Types.LiftedRep
|
| 1309 | 1309 | |
| 1310 | 1310 | module Data.List where
|
| 1311 | - -- Safety: Safe
|
|
| 1311 | + -- Safety: Trustworthy
|
|
| 1312 | 1312 | (!!) :: forall a. GHC.Internal.Stack.Types.HasCallStack => [a] -> GHC.Internal.Types.Int -> a
|
| 1313 | 1313 | (!?) :: forall a. [a] -> GHC.Internal.Types.Int -> GHC.Internal.Maybe.Maybe a
|
| 1314 | 1314 | (++) :: forall a. [a] -> [a] -> [a]
|
| ... | ... | @@ -746,7 +746,7 @@ module Data.Bits where |
| 746 | 746 | toIntegralSized :: forall a b. (GHC.Internal.Real.Integral a, GHC.Internal.Real.Integral b, Bits a, Bits b) => a -> GHC.Internal.Maybe.Maybe b
|
| 747 | 747 | |
| 748 | 748 | module Data.Bool where
|
| 749 | - -- Safety: Safe
|
|
| 749 | + -- Safety: Trustworthy
|
|
| 750 | 750 | (&&) :: Bool -> Bool -> Bool
|
| 751 | 751 | type Bool :: *
|
| 752 | 752 | data Bool = False | True
|
| ... | ... | @@ -1308,7 +1308,7 @@ module Data.Kind where |
| 1308 | 1308 | type Type = TYPE GHC.Internal.Types.LiftedRep
|
| 1309 | 1309 | |
| 1310 | 1310 | module Data.List where
|
| 1311 | - -- Safety: Safe
|
|
| 1311 | + -- Safety: Trustworthy
|
|
| 1312 | 1312 | (!!) :: forall a. GHC.Internal.Stack.Types.HasCallStack => [a] -> GHC.Internal.Types.Int -> a
|
| 1313 | 1313 | (!?) :: forall a. [a] -> GHC.Internal.Types.Int -> GHC.Internal.Maybe.Maybe a
|
| 1314 | 1314 | (++) :: forall a. [a] -> [a] -> [a]
|
| ... | ... | @@ -746,7 +746,7 @@ module Data.Bits where |
| 746 | 746 | toIntegralSized :: forall a b. (GHC.Internal.Real.Integral a, GHC.Internal.Real.Integral b, Bits a, Bits b) => a -> GHC.Internal.Maybe.Maybe b
|
| 747 | 747 | |
| 748 | 748 | module Data.Bool where
|
| 749 | - -- Safety: Safe
|
|
| 749 | + -- Safety: Trustworthy
|
|
| 750 | 750 | (&&) :: Bool -> Bool -> Bool
|
| 751 | 751 | type Bool :: *
|
| 752 | 752 | data Bool = False | True
|
| ... | ... | @@ -1308,7 +1308,7 @@ module Data.Kind where |
| 1308 | 1308 | type Type = TYPE GHC.Internal.Types.LiftedRep
|
| 1309 | 1309 | |
| 1310 | 1310 | module Data.List where
|
| 1311 | - -- Safety: Safe
|
|
| 1311 | + -- Safety: Trustworthy
|
|
| 1312 | 1312 | (!!) :: forall a. GHC.Internal.Stack.Types.HasCallStack => [a] -> GHC.Internal.Types.Int -> a
|
| 1313 | 1313 | (!?) :: forall a. [a] -> GHC.Internal.Types.Int -> GHC.Internal.Maybe.Maybe a
|
| 1314 | 1314 | (++) :: forall a. [a] -> [a] -> [a]
|