probability-0.2.1: Probabilistic Functional Programming

Numeric.Probability.Example.Collection

Contents

Synopsis

Documentation

type Collection a = [a]Source

select1 :: Fractional prob => Collection a -> T prob aSource

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

cards

data Suit Source

Constructors

Club 
Spade 
Heart 
Diamond 

Instances

data Rank Source

Constructors

Plain Int 
Jack 
Queen 
King 
Ace 

Instances

type Card = (Rank, Suit)Source

Example

value :: Card -> IntSource

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.

win :: ([Card], b) -> BoolSource

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