| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell98 |
RSPP
Contents
- data Pledge c = Pledge {
- pledgeClauses :: [PledgeClause c]
- pledgeLimit :: c
- data PledgeClause c
- = FixedPledge c
- | RationalPledge { }
- solve :: (Foldable t, Ord c, Fractional c) => t (Pledge c) -> c
- evalClause :: (Ord c, Fractional c) => c -> PledgeClause c -> c
- evalPledge :: (Ord c, Fractional c) => c -> Pledge c -> c
- evalPledges :: (Foldable t, Ord c, Fractional c) => c -> t (Pledge c) -> c
- pledgeMax :: Pledge c -> c
- pledgeMin :: (Ord c, Fractional c) => Pledge c -> c
- maxPledges :: (Foldable t, Num c) => t (Pledge c) -> c
- minPledges :: (Foldable t, Ord c, Fractional c) => t (Pledge c) -> c
Types
Pledge
A single pledge. Collect these in a Foldable (ie. List), and calculate the total with solve.
The c type parameter is for your currency datatype, ie. Centi from Data.Fixed.
Constructors
| Pledge | |
Fields
| |
PledgeClause
data PledgeClause c Source
A clause within a pledge, describing its behaviour.
The clauses within the pledge are added together, but may never exceed the pledgeLimit.
Constructors
| FixedPledge c | Simply contribute a fixed amount |
| RationalPledge | |
Instances
| Eq c => Eq (PledgeClause c) | |
| Read c => Read (PledgeClause c) | |
| Show c => Show (PledgeClause c) |
Functions
Arguments
| :: (Foldable t, Ord c, Fractional c) | |
| => t (Pledge c) | All pledges |
| -> c | The maximum consistent total |
The key function: it does a binary search to find the maximum total which satisfies all pledges.
Arguments
| :: (Ord c, Fractional c) | |
| => c | The total raised, including this clause |
| -> PledgeClause c | The clause to evaluate |
| -> c | What this clause contributes to the given total |
Given a particular total, how much did this clause contribute to that total?
Arguments
| :: (Ord c, Fractional c) | |
| => c | The total raised, including this pledge |
| -> Pledge c | The pledge to evaluate |
| -> c | What this pledge contributes to the given total |
Given a particular total, how much of it was this pledge? Note: the given total includes the total of this pledge!
Arguments
| :: (Foldable t, Ord c, Fractional c) | |
| => c | The total to evaluate against |
| -> t (Pledge c) | All pledges |
| -> c | The total of all pledges evaluated against the given total |
Given a particular total, what is the total of all the pledges?
Note: This may not give a valid result! Use solve for that.
pledgeMax :: Pledge c -> c Source
The most this pledge could contribute. This currently just uses the pledge's limit, though this may not always be quite right. Consider the following pledge: Pledge [FixedPledge 10] 100 The limit of 100 will certainly never be reached.
pledgeMin :: (Ord c, Fractional c) => Pledge c -> c Source
The least this pledge may contribute. May be above 0 if it contains a FixedPledge clause.
maxPledges :: (Foldable t, Num c) => t (Pledge c) -> c Source
The highest conceivable total that these pledges may contribute, based on their limits. Note that it may not be possible to actually reach this total.
minPledges :: (Foldable t, Ord c, Fractional c) => t (Pledge c) -> c Source
The lowest conceivable total that these pledges may contribute.