probability-0.2.5.2: Probabilistic Functional Programming

Numeric.Probability.Example.Collection

Synopsis

# Documentation

type Collection a = [a] Source #

selectOne :: Fractional prob => StateT (Collection a) (T prob) a Source #

select1 :: Fractional prob => Collection a -> T prob a Source #

select2 :: Fractional prob => Collection a -> T prob (a, a) Source #

select :: Fractional prob => Int -> Collection a -> T prob [a] Source #

# Example collections

## marbles

data Marble Source #

Constructors

 R G B
Instances
 Source # Instance detailsDefined in Numeric.Probability.Example.Collection Methods(==) :: Marble -> Marble -> Bool #(/=) :: Marble -> Marble -> Bool # Source # Instance detailsDefined in Numeric.Probability.Example.Collection Methods(<) :: Marble -> Marble -> Bool #(<=) :: Marble -> Marble -> Bool #(>) :: Marble -> Marble -> Bool #(>=) :: Marble -> Marble -> Bool #max :: Marble -> Marble -> Marble #min :: Marble -> Marble -> Marble # Source # Instance detailsDefined in Numeric.Probability.Example.Collection MethodsshowsPrec :: Int -> Marble -> ShowS #showList :: [Marble] -> ShowS #

## cards

data Suit Source #

Constructors

Instances
 Source # Instance detailsDefined in Numeric.Probability.Example.Collection Methodssucc :: Suit -> Suit #pred :: Suit -> Suit #toEnum :: Int -> Suit #fromEnum :: Suit -> Int #enumFrom :: Suit -> [Suit] #enumFromThen :: Suit -> Suit -> [Suit] #enumFromTo :: Suit -> Suit -> [Suit] #enumFromThenTo :: Suit -> Suit -> Suit -> [Suit] # Source # Instance detailsDefined in Numeric.Probability.Example.Collection Methods(==) :: Suit -> Suit -> Bool #(/=) :: Suit -> Suit -> Bool # Source # Instance detailsDefined in Numeric.Probability.Example.Collection Methodscompare :: Suit -> Suit -> Ordering #(<) :: Suit -> Suit -> Bool #(<=) :: Suit -> Suit -> Bool #(>) :: Suit -> Suit -> Bool #(>=) :: Suit -> Suit -> Bool #max :: Suit -> Suit -> Suit #min :: Suit -> Suit -> Suit # Source # Instance detailsDefined in Numeric.Probability.Example.Collection MethodsshowsPrec :: Int -> Suit -> ShowS #show :: Suit -> String #showList :: [Suit] -> ShowS #

data Rank Source #

Constructors

 Plain Int Jack Queen King Ace
Instances
 Source # Instance detailsDefined in Numeric.Probability.Example.Collection Methods(==) :: Rank -> Rank -> Bool #(/=) :: Rank -> Rank -> Bool # Source # Instance detailsDefined in Numeric.Probability.Example.Collection Methodscompare :: Rank -> Rank -> Ordering #(<) :: Rank -> Rank -> Bool #(<=) :: Rank -> Rank -> Bool #(>) :: Rank -> Rank -> Bool #(>=) :: Rank -> Rank -> Bool #max :: Rank -> Rank -> Rank #min :: Rank -> Rank -> Rank # Source # Instance detailsDefined in Numeric.Probability.Example.Collection MethodsshowsPrec :: Int -> Rank -> ShowS #show :: Rank -> String #showList :: [Rank] -> ShowS #

type Card = (Rank, Suit) Source #

# Example

mini-blackjack: draw 2 cards, and if value is less than 14, continue drawing until value equals or exceeds 14. if values exceeds 21, you lose, otherwise you win.

draw :: Fractional prob => ([Card], Collection Card) -> T prob ([Card], Collection Card) Source #

win :: ([Card], b) -> Bool Source #

chanceWin :: (Fractional prob, Ord prob, Random prob) => T (T prob Bool) Source #