    {-# LANGUAGE Trustworthy #-}
    {-# LANGUAGE BangPatterns, CPP, GeneralizedNewtypeDeriving, MagicHash,
      NoImplicitPrelude, UnboxedTuples #-}

    module GHC.Event.Unique
        (
          UniqueSource
        , Unique(..)
        , newSource
        , newUnique
        ) where

    import GHC.Base
    import GHC.Num(Num)
    import GHC.Show(Show(..))

    #include "MachDeps.h"

    data UniqueSource = US (MutableByteArray# RealWorld)

    newtype Unique = Unique { Unique -> Int
    asInt :: Int }
        deriving ( Unique -> Unique -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Unique -> Unique -> Bool
    $c/= :: Unique -> Unique -> Bool
    == :: Unique -> Unique -> Bool
    $c== :: Unique -> Unique -> Bool
    Eq  -- ^ @since 4.4.0.0
                 , Eq Unique
    Unique -> Unique -> Bool
    Unique -> Unique -> Ordering
    Unique -> Unique -> Unique
    forall a.
    Eq a
    -> (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    min :: Unique -> Unique -> Unique
    $cmin :: Unique -> Unique -> Unique
    max :: Unique -> Unique -> Unique
    $cmax :: Unique -> Unique -> Unique
    >= :: Unique -> Unique -> Bool
    $c>= :: Unique -> Unique -> Bool
    > :: Unique -> Unique -> Bool
    $c> :: Unique -> Unique -> Bool
    <= :: Unique -> Unique -> Bool
    $c<= :: Unique -> Unique -> Bool
    < :: Unique -> Unique -> Bool
    $c< :: Unique -> Unique -> Bool
    compare :: Unique -> Unique -> Ordering
    $ccompare :: Unique -> Unique -> Ordering
    Ord -- ^ @since 4.4.0.0
                 , Integer -> Unique
    Unique -> Unique
    Unique -> Unique -> Unique
    forall a.
    (a -> a -> a)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> (a -> a)
    -> (a -> a)
    -> (a -> a)
    -> (Integer -> a)
    -> Num a
    fromInteger :: Integer -> Unique
    $cfromInteger :: Integer -> Unique
    signum :: Unique -> Unique
    $csignum :: Unique -> Unique
    abs :: Unique -> Unique
    $cabs :: Unique -> Unique
    negate :: Unique -> Unique
    $cnegate :: Unique -> Unique
    * :: Unique -> Unique -> Unique
    $c* :: Unique -> Unique -> Unique
    - :: Unique -> Unique -> Unique
    $c- :: Unique -> Unique -> Unique
    + :: Unique -> Unique -> Unique
    $c+ :: Unique -> Unique -> Unique
    Num -- ^ @since 4.4.0.0
                 )

    -- | @since 4.3.1.0
    instance Show Unique where
        show :: Unique -> String
    show = forall a. Show a => a -> String
    show forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Int
    asInt

    newSource :: IO UniqueSource
    newSource :: IO UniqueSource
    newSource = forall a. (State# RealWorld -> (# State# RealWorld, a #)) -> IO a
    IO forall a b. (a -> b) -> a -> b
    $ \State# RealWorld
    s ->
      case forall d. Int# -> State# d -> (# State# d, MutableByteArray# d #)
    newByteArray# Int#
    size State# RealWorld
    s of
        (# State# RealWorld
    s', MutableByteArray# RealWorld
    mba #) -> (# State# RealWorld
    s', MutableByteArray# RealWorld -> UniqueSource
    US MutableByteArray# RealWorld
    mba #)
      where
        !(I# Int#
    size) = SIZEOF_HSINT

    newUnique :: UniqueSource -> IO Unique
    newUnique :: UniqueSource -> IO Unique
    newUnique (US MutableByteArray# RealWorld
    mba) = forall a. (State# RealWorld -> (# State# RealWorld, a #)) -> IO a
    IO forall a b. (a -> b) -> a -> b
    $ \State# RealWorld
    s ->
      case forall d.
    MutableByteArray# d
    -> Int# -> Int# -> State# d -> (# State# d, Int# #)
    fetchAddIntArray# MutableByteArray# RealWorld
    mba Int#
    0# Int#
    1# State# RealWorld
    s of
        (# State# RealWorld
    s', Int#
    a #) -> (# State# RealWorld
    s', Int -> Unique
    Unique (Int# -> Int
    I# Int#
    a) #)
    {-# INLINE newUnique #-}