{-# LANGUAGE Unsafe #-}
{-# LANGUAGE MagicHash, UnboxedTuples, TypeFamilies, DeriveDataTypeable,
MultiParamTypeClasses, FlexibleInstances, NoImplicitPrelude #-}
module GHC.Exts
(
Int(..),Word(..),Float(..),Double(..),
Char(..),
Ptr(..), FunPtr(..),
maxTupleSize,
module GHC.Prim,
module GHC.Prim.Ext,
shiftL#, shiftRL#, iShiftL#, iShiftRA#, iShiftRL#,
uncheckedShiftL64#, uncheckedShiftRL64#,
uncheckedIShiftL64#, uncheckedIShiftRA64#,
isTrue#,
atomicModifyMutVar#,
resizeSmallMutableArray#,
build, augment,
IsString(..),
breakpoint, breakpointCond,
lazy, inline, oneShot,
runRW#,
Data.Coerce.coerce, Data.Coerce.Coercible,
type (~~),
GHC.Prim.TYPE, RuntimeRep(..), VecCount(..), VecElem(..),
Down(..), groupWith, sortWith, the,
traceEvent,
SpecConstrAnnotation(..),
currentCallStack,
Constraint,
Any,
IsList(..)
) where
import GHC.Prim hiding ( coerce, TYPE )
import qualified GHC.Prim
import qualified GHC.Prim.Ext
import GHC.Base hiding ( coerce )
import GHC.Word
import GHC.Int
import GHC.Ptr
import GHC.Stack
import qualified Data.Coerce
import Data.String
import Data.OldList
import Data.Data
import Data.Ord
import Data.Version ( Version(..), makeVersion )
import qualified Debug.Trace
import Control.Applicative (ZipList(..))
maxTupleSize :: Int
maxTupleSize :: Int
maxTupleSize = Int
62
the :: Eq a => [a] -> a
the :: [a] -> a
the (a
x:[a]
xs)
| (a -> Bool) -> [a] -> Bool
forall a. (a -> Bool) -> [a] -> Bool
all (a
x a -> a -> Bool
forall a. Eq a => a -> a -> Bool
==) [a]
xs = a
x
| Bool
otherwise = [Char] -> a
forall a. [Char] -> a
errorWithoutStackTrace [Char]
"GHC.Exts.the: non-identical elements"
the [] = [Char] -> a
forall a. [Char] -> a
errorWithoutStackTrace [Char]
"GHC.Exts.the: empty list"
sortWith :: Ord b => (a -> b) -> [a] -> [a]
sortWith :: (a -> b) -> [a] -> [a]
sortWith a -> b
f = (a -> a -> Ordering) -> [a] -> [a]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (\a
x a
y -> b -> b -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (a -> b
f a
x) (a -> b
f a
y))
{-# INLINE groupWith #-}
groupWith :: Ord b => (a -> b) -> [a] -> [[a]]
groupWith :: (a -> b) -> [a] -> [[a]]
groupWith a -> b
f [a]
xs = (forall b. ([a] -> b -> b) -> b -> b) -> [[a]]
forall a. (forall b. (a -> b -> b) -> b -> b) -> [a]
build (\[a] -> b -> b
c b
n -> ([a] -> b -> b) -> b -> (a -> a -> Bool) -> [a] -> b
forall a lst.
([a] -> lst -> lst) -> lst -> (a -> a -> Bool) -> [a] -> lst
groupByFB [a] -> b -> b
c b
n (\a
x a
y -> a -> b
f a
x b -> b -> Bool
forall a. Eq a => a -> a -> Bool
== a -> b
f a
y) ((a -> b) -> [a] -> [a]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortWith a -> b
f [a]
xs))
{-# INLINE [0] groupByFB #-}
groupByFB :: ([a] -> lst -> lst) -> lst -> (a -> a -> Bool) -> [a] -> lst
groupByFB :: ([a] -> lst -> lst) -> lst -> (a -> a -> Bool) -> [a] -> lst
groupByFB [a] -> lst -> lst
c lst
n a -> a -> Bool
eq [a]
xs0 = [a] -> lst
groupByFBCore [a]
xs0
where groupByFBCore :: [a] -> lst
groupByFBCore [] = lst
n
groupByFBCore (a
x:[a]
xs) = [a] -> lst -> lst
c (a
xa -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
ys) ([a] -> lst
groupByFBCore [a]
zs)
where ([a]
ys, [a]
zs) = (a -> Bool) -> [a] -> ([a], [a])
forall a. (a -> Bool) -> [a] -> ([a], [a])
span (a -> a -> Bool
eq a
x) [a]
xs
traceEvent :: String -> IO ()
traceEvent :: [Char] -> IO ()
traceEvent = [Char] -> IO ()
Debug.Trace.traceEventIO
{-# DEPRECATED traceEvent "Use 'Debug.Trace.traceEvent' or 'Debug.Trace.traceEventIO'" #-}
data SpecConstrAnnotation = NoSpecConstr | ForceSpecConstr
deriving ( Data
, Eq
)
class IsList l where
type Item l
fromList :: [Item l] -> l
fromListN :: Int -> [Item l] -> l
fromListN Int
_ = [Item l] -> l
forall l. IsList l => [Item l] -> l
fromList
toList :: l -> [Item l]
instance IsList [a] where
type (Item [a]) = a
fromList :: [Item [a]] -> [a]
fromList = [Item [a]] -> [a]
forall a. a -> a
id
toList :: [a] -> [Item [a]]
toList = [a] -> [Item [a]]
forall a. a -> a
id
instance IsList (ZipList a) where
type Item (ZipList a) = a
fromList :: [Item (ZipList a)] -> ZipList a
fromList = [Item (ZipList a)] -> ZipList a
forall a. [a] -> ZipList a
ZipList
toList :: ZipList a -> [Item (ZipList a)]
toList = ZipList a -> [Item (ZipList a)]
forall a. ZipList a -> [a]
getZipList
instance IsList (NonEmpty a) where
type Item (NonEmpty a) = a
fromList :: [Item (NonEmpty a)] -> NonEmpty a
fromList (Item (NonEmpty a)
a:[Item (NonEmpty a)]
as) = a
Item (NonEmpty a)
a a -> [a] -> NonEmpty a
forall a. a -> [a] -> NonEmpty a
:| [a]
[Item (NonEmpty a)]
as
fromList [] = [Char] -> NonEmpty a
forall a. [Char] -> a
errorWithoutStackTrace [Char]
"NonEmpty.fromList: empty list"
toList :: NonEmpty a -> [Item (NonEmpty a)]
toList ~(a
a :| [a]
as) = a
a a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [a]
as
instance IsList Version where
type (Item Version) = Int
fromList :: [Item Version] -> Version
fromList = [Int] -> Version
[Item Version] -> Version
makeVersion
toList :: Version -> [Item Version]
toList = Version -> [Int]
Version -> [Item Version]
versionBranch
instance IsList CallStack where
type (Item CallStack) = (String, SrcLoc)
fromList :: [Item CallStack] -> CallStack
fromList = [([Char], SrcLoc)] -> CallStack
[Item CallStack] -> CallStack
fromCallSiteList
toList :: CallStack -> [Item CallStack]
toList = CallStack -> [([Char], SrcLoc)]
CallStack -> [Item CallStack]
getCallStack
atomicModifyMutVar#
:: MutVar# s a
-> (a -> b)
-> State# s
-> (# State# s, c #)
atomicModifyMutVar# :: MutVar# s a -> (a -> b) -> State# s -> (# State# s, c #)
atomicModifyMutVar# MutVar# s a
mv a -> b
f State# s
s =
case (# State# s, a, b #) -> (# State# s, Any, (Any, c) #)
unsafeCoerce# (MutVar# s a -> (a -> b) -> State# s -> (# State# s, a, b #)
forall d a b.
MutVar# d a -> (a -> b) -> State# d -> (# State# d, a, b #)
atomicModifyMutVar2# MutVar# s a
mv a -> b
f State# s
s) of
(# State# s
s', Any
_, ~(Any
_, c
res) #) -> (# State# s
s', c
res #)
resizeSmallMutableArray#
:: SmallMutableArray# s a
-> Int#
-> a
-> State# s
-> (# State# s, SmallMutableArray# s a #)
resizeSmallMutableArray# :: SmallMutableArray# s a
-> Int# -> a -> State# s -> (# State# s, SmallMutableArray# s a #)
resizeSmallMutableArray# SmallMutableArray# s a
arr0 Int#
szNew a
a State# s
s0 =
case SmallMutableArray# s a -> State# s -> (# State# s, Int# #)
forall d a.
SmallMutableArray# d a -> State# d -> (# State# d, Int# #)
getSizeofSmallMutableArray# SmallMutableArray# s a
arr0 State# s
s0 of
(# State# s
s1, Int#
szOld #) -> if Int# -> Bool
isTrue# (Int#
szNew Int# -> Int# -> Int#
<# Int#
szOld)
then case SmallMutableArray# s a -> Int# -> State# s -> State# s
forall d a. SmallMutableArray# d a -> Int# -> State# d -> State# d
shrinkSmallMutableArray# SmallMutableArray# s a
arr0 Int#
szNew State# s
s1 of
State# s
s2 -> (# State# s
s2, SmallMutableArray# s a
arr0 #)
else if Int# -> Bool
isTrue# (Int#
szNew Int# -> Int# -> Int#
># Int#
szOld)
then case Int# -> a -> State# s -> (# State# s, SmallMutableArray# s a #)
forall a d.
Int# -> a -> State# d -> (# State# d, SmallMutableArray# d a #)
newSmallArray# Int#
szNew a
a State# s
s1 of
(# State# s
s2, SmallMutableArray# s a
arr1 #) -> case SmallMutableArray# s a
-> Int#
-> SmallMutableArray# s a
-> Int#
-> Int#
-> State# s
-> State# s
forall d a.
SmallMutableArray# d a
-> Int#
-> SmallMutableArray# d a
-> Int#
-> Int#
-> State# d
-> State# d
copySmallMutableArray# SmallMutableArray# s a
arr0 Int#
0# SmallMutableArray# s a
arr1 Int#
0# Int#
szOld State# s
s2 of
State# s
s3 -> (# State# s
s3, SmallMutableArray# s a
arr1 #)
else (# State# s
s1, SmallMutableArray# s a
arr0 #)