{-# LANGUAGE Unsafe #-}{-# LANGUAGE MagicHash, UnboxedTuples, TypeFamilies, DeriveDataTypeable, MultiParamTypeClasses, FlexibleInstances, NoImplicitPrelude #-}------------------------------------------------------------------------------- |-- Module : GHC.Exts-- Copyright : (c) The University of Glasgow 2002-- License : see libraries/base/LICENSE---- Maintainer : cvs-ghc@haskell.org-- Stability : internal-- Portability : non-portable (GHC Extensions)---- GHC Extensions: this is the Approved Way to get at GHC-specific extensions.---- Note: no other base module should import this module.-----------------------------------------------------------------------------moduleGHC.Exts(-- * Representations of some basic typesInt(..),Word(..),Float(..),Double(..),Char(..),Ptr (..),FunPtr (..),-- * The maximum tuple sizemaxTupleSize ,-- * Primitive operationsmoduleGHC.Prim,shiftL# ,shiftRL# ,iShiftL# ,iShiftRA# ,iShiftRL# ,uncheckedShiftL64# ,uncheckedShiftRL64# ,uncheckedIShiftL64# ,uncheckedIShiftRA64# ,isTrue#,-- * Fusionbuild ,augment ,-- * Overloaded string literalsIsString (..),-- * Debuggingbreakpoint ,breakpointCond ,-- * Ids with special behaviourlazy,inline,oneShot,-- * Running 'RealWorld' state transformersrunRW#,-- * Safe coercions---- | These are available from the /Trustworthy/ module "Data.Coerce" as well---- @since 4.7.0.0Data.Coerce.coerce,Data.Coerce.Coercible,-- * Equalitytype(~~),-- * Representation polymorphismGHC.Prim.TYPE,RuntimeRep(..),VecCount(..),VecElem(..),-- * Transform comprehensionsDown (..),groupWith ,sortWith ,the ,-- * Event loggingtraceEvent ,-- * SpecConstr annotationsSpecConstrAnnotation (..),-- * The call stackcurrentCallStack ,-- * The Constraint kindConstraint,-- * The Any typeAny,-- * Overloaded listsIsList (..))whereimportGHC.Primhiding(coerce,TYPE)importqualifiedGHC.PrimimportGHC.Base hiding(coerce)importGHC.Word importGHC.Int importGHC.Ptr importGHC.Stack importqualifiedData.Coerce importData.String importData.OldList importData.Data importData.Ord importData.Version (Version (..),makeVersion )importqualifiedDebug.Trace -- XXX This should really be in Data.Tuple, where the definitions aremaxTupleSize::IntmaxTupleSize =62-- | 'the' ensures that all the elements of the list are identical-- and then returns that unique elementthe::Eqa =>[a ]->a the (x :xs )|all (x ==)xs =x |otherwise =errorWithoutStackTrace "GHC.Exts.the: non-identical elements"the[]=errorWithoutStackTrace "GHC.Exts.the: empty list"-- | The 'sortWith' function sorts a list of elements using the-- user supplied function to project something out of each elementsortWith::Ordb =>(a ->b )->[a ]->[a ]sortWith f =sortBy (\x y ->compare(f x )(f y ))-- | The 'groupWith' function uses the user supplied function which-- projects an element out of every list element in order to first sort the-- input list and then to form groups by equality on these projected elements{-# INLINEgroupWith#-}groupWith::Ordb =>(a ->b )->[a ]->[[a ]]groupWith f xs =build (\c n ->groupByFB c n (\x y ->f x ==f y )(sortWith f xs )){-# INLINE[0]groupByFB#-}-- See Note [Inline FB functions] in GHC.ListgroupByFB::([a ]->lst ->lst )->lst ->(a ->a ->Bool)->[a ]->lst groupByFB c n eq xs0 =groupByFBCore xs0 wheregroupByFBCore []=n groupByFBCore(x :xs )=c (x :ys )(groupByFBCore zs )where(ys ,zs )=span (eq x )xs -- ------------------------------------------------------------------------------- tracingtraceEvent::String ->IO()traceEvent =Debug.Trace.traceEventIO {-# DEPRECATEDtraceEvent"Use 'Debug.Trace.traceEvent' or 'Debug.Trace.traceEventIO'"#-}-- deprecated in 7.4{- ********************************************************************** * * * SpecConstr annotation * * * ********************************************************************** -}-- Annotating a type with NoSpecConstr will make SpecConstr-- not specialise for arguments of that type.-- This data type is defined here, rather than in the SpecConstr module-- itself, so that importing it doesn't force stupidly linking the-- entire ghc package at runtimedataSpecConstrAnnotation =NoSpecConstr |ForceSpecConstr deriving(Data -- ^ @since 4.3.0.0,Eq-- ^ @since 4.3.0.0){- ********************************************************************** * * * The IsList class * * * ********************************************************************** -}-- | The 'IsList' class and its methods are intended to be used in-- conjunction with the OverloadedLists extension.---- @since 4.7.0.0classIsList l where-- | The 'Item' type function returns the type of items of the structure-- @l@.typeItem l -- | The 'fromList' function constructs the structure @l@ from the given-- list of @Item l@fromList ::[Item l ]->l -- | The 'fromListN' function takes the input list's length as a hint. Its-- behaviour should be equivalent to 'fromList'. The hint can be used to-- construct the structure @l@ more efficiently compared to 'fromList'. If-- the given hint does not equal to the input list's length the behaviour of-- 'fromListN' is not specified.fromListN ::Int->[Item l ]->l fromListN _=fromList -- | The 'toList' function extracts a list of @Item l@ from the structure @l@.-- It should satisfy fromList . toList = id.toList ::l ->[Item l ]-- | @since 4.7.0.0instanceIsList [a ]wheretype(Item[a ])=a fromList =id toList =id -- | @since 4.9.0.0instanceIsList (NonEmpty a )wheretypeItem(NonEmpty a )=a fromList (a :as)=a :| asfromList[]=errorWithoutStackTrace "NonEmpty.fromList: empty list"toList ~(a :| as)=a :as-- | @since 4.8.0.0instanceIsList Version wheretype(ItemVersion )=IntfromList =makeVersion toList =versionBranch-- | Be aware that 'fromList . toList = id' only for unfrozen 'CallStack's,-- since 'toList' removes frozenness information.---- @since 4.9.0.0instanceIsList CallStack wheretype(ItemCallStack )=(String ,SrcLoc )fromList =fromCallSiteList toList =getCallStack