-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Sequential numbers that allow arbitrarily inserting numbers - for containers -- -- Sequential index numbers between 0.0 and 1.0 that allow arbitrarily -- inserting new numbers in between. They can possibly used for -- disk-based and other special containers, where adding a new element -- without changing the indexes of the other elements is important. -- Conceptually, SequentialIndex denotes a path to an element in an -- imaginary binary tree. However, leafs can only be on the right side of -- their parent. I.e. the path must end with a '1' (or be the path to the -- root node, 0.0). 1.0 denotes the invalid node. @package sequential-index @version 0.2 module Data.SequentialIndex -- | An arbitrary-precision number between 0.0 and 1.0. To create new -- numbers, use between. -- -- Each number consist of a mantissa (>= 0) and an -- exponent (> 0), so that its numeric value equals -- mantissa x * 2 ^ (1 - exponent x). The constraint that it -- must lie between 0.0 and 1.0 is enforced in the constructors. -- -- It is possible to span a hypothetical tree in this number scheme. -- Discarding the last binary digit of the mantissa, which has to be a 1, -- each digit of the mantissa denotes a branch in this hypothetical -- binary tree. So a whole SequentialIndex (if it ends with 1) -- corresponds with a path in a binary tree. data SequentialIndex -- | Extracts the mantissa. mantissa :: SequentialIndex -> Integer -- | Extracts the exponent. exponent :: SequentialIndex -> Int -- | The lowest possible number: 0.0. zero :: SequentialIndex -- | The highest possible number: 1.0. one :: SequentialIndex -- | The root of a hypothetical binary tree. root :: SequentialIndex -- | Construct a SequentialIndex from its mantissa and -- exponent. -- -- Errors are checked and result in a run-time error. sequentialIndex :: Integer -> Int -> SequentialIndex -- | Construct a SequentialIndex from its mantissa and -- exponent. -- -- Errors are not checked. unsafeSequentialIndex :: Integer -> Int -> SequentialIndex -- | Construct a SequentialIndex from a list of boolean digits. The -- exponent equals the number of digits. tryFromBools :: [Bool] -> Maybe SequentialIndex -- | Compute a number right in the middle of the arguments. -- --
--   (x + y) / 2
--   
between :: SequentialIndex -> SequentialIndex -> SequentialIndex -- | Add digits in front of the mantissa. prefixBits :: Int -> Integer -> SequentialIndex -> SequentialIndex -- | Build a number from a list of fixed-width mantissa segments. build :: Int -> [Integer] -> SequentialIndex -- | Build a number from a list of fixed-width mantissa segments. buildBits :: (Bits a, Integral a) => [a] -> SequentialIndex -- | Get the left child of the current path in the hypothetical tree. leftChild :: SequentialIndex -> Maybe SequentialIndex -- | Get the right child of the current path in the hypothetical tree. rightChild :: SequentialIndex -> Maybe SequentialIndex -- | Get the parent of the current path in the hypothetical tree. parent :: SequentialIndex -> Maybe SequentialIndex -- | Convert a SequentialIndex to a binary representation. toByteString :: SequentialIndex -> ByteString -- | Convert a SequentialIndex from its binary representation. fromByteString :: ByteString -> Maybe SequentialIndex instance Eq SequentialIndex instance Show SequentialIndex instance Ord SequentialIndex instance Bounded SequentialIndex module Data.SequentialIndex.Open data SequentialIndex mantissa :: SequentialIndex -> Integer exponent :: SequentialIndex -> Int sequentialIndex :: Int -> Integer -> SequentialIndex tryFromBools :: [Bool] -> Maybe SequentialIndex toClosed :: SequentialIndex -> SequentialIndex fromClosed :: SequentialIndex -> Maybe SequentialIndex root :: SequentialIndex leftChild :: SequentialIndex -> SequentialIndex rightChild :: SequentialIndex -> SequentialIndex parent :: SequentialIndex -> Maybe SequentialIndex prefixBits :: Int -> Integer -> SequentialIndex -> SequentialIndex toByteString :: SequentialIndex -> ByteString fromByteString :: ByteString -> Maybe SequentialIndex instance Eq SequentialIndex instance Ord SequentialIndex instance Show SequentialIndex