-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A loose port of Twitter Snowflake to Haskell. Generates arbitrary precision, unique, time-sortable identifiers.
--   
--   A loose port of Twitter Snowflake to Haskell. Generates arbitrary
--   precision, unique, time-sortable identifiers.
@package snowflake
@version 0.1.1.1


-- | This generates unique(guaranteed) identifiers build from time stamp,
--   counter(inside same millisecond) and node id - if you wish to generate
--   ids across several nodes. Identifiers are convertible to
--   <a>Integer</a> values which are monotonically increasing with respect
--   to time.
module Data.Snowflake

-- | Configuration that specifies how much bits are used for each part of
--   the id. There are no limits to total bit sum.
data SnowflakeConfig
SnowflakeConfig :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> SnowflakeConfig
[confTimeBits] :: SnowflakeConfig -> {-# UNPACK #-} !Int
[confCountBits] :: SnowflakeConfig -> {-# UNPACK #-} !Int
[confNodeBits] :: SnowflakeConfig -> {-# UNPACK #-} !Int

-- | Generated identifier. Can be converted to <a>Integer</a>.
data Snowflake

-- | Generator which contains needed state. You should use
--   <a>newSnowflakeGen</a> to create instances.
data SnowflakeGen

-- | Create a new generator. Takes a configuration and node id.
newSnowflakeGen :: SnowflakeConfig -> Integer -> IO SnowflakeGen

-- | Generates next id. The bread and butter. See module description for
--   details.
nextSnowflake :: SnowflakeGen -> IO Snowflake

-- | Default configuration using 40 bits for time, 16 for count and 8 for
--   node id.
defaultConfig :: SnowflakeConfig

-- | Converts an identifier to an integer with respect to configuration
--   used to generate it.
snowflakeToInteger :: Snowflake -> Integer
instance GHC.Classes.Eq Data.Snowflake.Snowflake
instance GHC.Show.Show Data.Snowflake.SnowflakeConfig
instance GHC.Classes.Eq Data.Snowflake.SnowflakeConfig
instance GHC.Show.Show Data.Snowflake.Snowflake
