1 -----------------------------------------------------------------------------
4 -- Copyright : (c) The University of Glasgow 2002
5 -- License : see libraries/base/LICENSE
7 -- Maintainer : cvs-ghc@haskell.org
8 -- Stability : internal
9 -- Portability : non-portable (GHC Extensions)
11 -- GHC Extensions: this is the Approved Way to get at GHC-specific extensions.
13 -----------------------------------------------------------------------------
17 -- * Representations of some basic types
18 Int(..),Word(..),Float(..),Double(..),Integer(..),Char(..),
21 -- * Primitive operations
23 shiftL#, shiftRL#, iShiftL#, iShiftRA#, iShiftRL#,
24 uncheckedShiftL64#, uncheckedShiftRL64#,
25 uncheckedIShiftL64#, uncheckedIShiftRA64#,
30 -- * Overloaded string literals
34 breakpoint, breakpointCond,
36 -- * Ids with special behaviour
39 -- * Transform comprehensions
40 groupWith, sortWith, the
56 -- | 'the' ensures that all the elements of the list are identical
57 -- and then returns that unique element
58 the :: Eq a => [a] -> a
61 | otherwise = error "GHC.Exts.the: non-identical elements"
62 the [] = error "GHC.Exts.the: empty list"
64 -- | The 'sortWith' function sorts a list of elements using the
65 -- user supplied function to project something out of each element
66 sortWith :: Ord b => (a -> b) -> [a] -> [a]
67 sortWith f = sortBy (\x y -> compare (f x) (f y))
69 -- | The 'groupWith' function uses the user supplied function which
70 -- projects an element out of every list element in order to to first sort the
71 -- input list and then to form groups by equality on these projected elements
72 groupWith :: Ord b => (a -> b) -> [a] -> [[a]]
73 groupWith f = groupBy (\x y -> f x == f y) . sortWith f