urn-random-0.1.0.0: A package for updatable discrete distributions

Safe HaskellNone
LanguageHaskell2010

Data.Urn.Internal

Contents

Synopsis

Types

Parameters of the trees

newtype Index Source #

Constructors

Index 

Fields

Instances

Eq Index Source # 

Methods

(==) :: Index -> Index -> Bool #

(/=) :: Index -> Index -> Bool #

Ord Index Source # 

Methods

compare :: Index -> Index -> Ordering #

(<) :: Index -> Index -> Bool #

(<=) :: Index -> Index -> Bool #

(>) :: Index -> Index -> Bool #

(>=) :: Index -> Index -> Bool #

max :: Index -> Index -> Index #

min :: Index -> Index -> Index #

NFData Index Source # 

Methods

rnf :: Index -> () #

newtype Size Source #

Constructors

Size 

Fields

Instances

Bounded Size Source # 
Enum Size Source # 

Methods

succ :: Size -> Size #

pred :: Size -> Size #

toEnum :: Int -> Size #

fromEnum :: Size -> Int #

enumFrom :: Size -> [Size] #

enumFromThen :: Size -> Size -> [Size] #

enumFromTo :: Size -> Size -> [Size] #

enumFromThenTo :: Size -> Size -> Size -> [Size] #

Eq Size Source # 

Methods

(==) :: Size -> Size -> Bool #

(/=) :: Size -> Size -> Bool #

Integral Size Source # 

Methods

quot :: Size -> Size -> Size #

rem :: Size -> Size -> Size #

div :: Size -> Size -> Size #

mod :: Size -> Size -> Size #

quotRem :: Size -> Size -> (Size, Size) #

divMod :: Size -> Size -> (Size, Size) #

toInteger :: Size -> Integer #

Num Size Source # 

Methods

(+) :: Size -> Size -> Size #

(-) :: Size -> Size -> Size #

(*) :: Size -> Size -> Size #

negate :: Size -> Size #

abs :: Size -> Size #

signum :: Size -> Size #

fromInteger :: Integer -> Size #

Ord Size Source # 

Methods

compare :: Size -> Size -> Ordering #

(<) :: Size -> Size -> Bool #

(<=) :: Size -> Size -> Bool #

(>) :: Size -> Size -> Bool #

(>=) :: Size -> Size -> Bool #

max :: Size -> Size -> Size #

min :: Size -> Size -> Size #

Real Size Source # 

Methods

toRational :: Size -> Rational #

Show Size Source # 

Methods

showsPrec :: Int -> Size -> ShowS #

show :: Size -> String #

showList :: [Size] -> ShowS #

Bits Size Source # 
FiniteBits Size Source # 
NFData Size Source # 

Methods

rnf :: Size -> () #

Tree types (and constructors)

data BTree a Source #

Constructors

BLeaf a 
BNode !(WTree a) !(WTree a) 

Instances

Eq a => Eq (BTree a) Source # 

Methods

(==) :: BTree a -> BTree a -> Bool #

(/=) :: BTree a -> BTree a -> Bool #

Ord a => Ord (BTree a) Source # 

Methods

compare :: BTree a -> BTree a -> Ordering #

(<) :: BTree a -> BTree a -> Bool #

(<=) :: BTree a -> BTree a -> Bool #

(>) :: BTree a -> BTree a -> Bool #

(>=) :: BTree a -> BTree a -> Bool #

max :: BTree a -> BTree a -> BTree a #

min :: BTree a -> BTree a -> BTree a #

Show a => Show (BTree a) Source # 

Methods

showsPrec :: Int -> BTree a -> ShowS #

show :: BTree a -> String #

showList :: [BTree a] -> ShowS #

NFData a => NFData (BTree a) Source # 

Methods

rnf :: BTree a -> () #

data WTree a Source #

Constructors

WTree 

Fields

Instances

Eq a => Eq (WTree a) Source # 

Methods

(==) :: WTree a -> WTree a -> Bool #

(/=) :: WTree a -> WTree a -> Bool #

Ord a => Ord (WTree a) Source # 

Methods

compare :: WTree a -> WTree a -> Ordering #

(<) :: WTree a -> WTree a -> Bool #

(<=) :: WTree a -> WTree a -> Bool #

(>) :: WTree a -> WTree a -> Bool #

(>=) :: WTree a -> WTree a -> Bool #

max :: WTree a -> WTree a -> WTree a #

min :: WTree a -> WTree a -> WTree a #

Show a => Show (WTree a) Source # 

Methods

showsPrec :: Int -> WTree a -> ShowS #

show :: WTree a -> String #

showList :: [WTree a] -> ShowS #

NFData a => NFData (WTree a) Source # 

Methods

rnf :: WTree a -> () #

pattern WLeaf :: forall a. Weight -> a -> WTree a Source #

pattern WNode :: forall a. Weight -> WTree a -> WTree a -> WTree a Source #

data Urn a Source #

Constructors

Urn 

Fields

Instances

Show a => Show (Urn a) Source #

This Show instance prints out the elements from most-weighted to least-weighted; however, do not rely on the order of equally-weighted elements, as this may depend on details of the implementation.

Methods

showsPrec :: Int -> Urn a -> ShowS #

show :: Urn a -> String #

showList :: [Urn a] -> ShowS #

NFData a => NFData (Urn a) Source # 

Methods

rnf :: Urn a -> () #

Sampling/lookup (WTrees and BTrees)

sample :: WTree a -> Index -> a Source #

bsample :: BTree a -> Index -> a Source #

Insertion (Urns)

insert :: Weight -> a -> Urn a -> Urn a Source #

uninsert :: Urn a -> (Weight, a, Weight, Maybe (Urn a)) Source #

Update and construct (WTrees)

update :: (Weight -> a -> (Weight, a)) -> WTree a -> Index -> (Weight, a, Weight, a, WTree a) Source #

replace :: Weight -> a -> WTree a -> Index -> (Weight, a, WTree a) Source #

General weight-based WTree traversal

foldWTree :: (Weight -> a -> b) -> (Weight -> b -> WTree a -> b) -> (Weight -> WTree a -> b -> b) -> Size -> WTree a -> b Source #

Raw random index generation

randomIndexWith :: Functor f => ((Word, Word) -> f Word) -> Urn a -> f Index Source #

Debugging