haddock updates
This commit is contained in:
		
							parent
							
								
									2c01541de1
								
							
						
					
					
						commit
						06e224dc4a
					
				@ -127,7 +127,9 @@ amountWithCommodity :: Commodity -> Amount -> Amount
 | 
				
			|||||||
amountWithCommodity c (Amount _ q _) = Amount c q Nothing
 | 
					amountWithCommodity c (Amount _ q _) = Amount c q Nothing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- | Convert an amount to the commodity of its assigned price, if any.  Notes:
 | 
					-- | Convert an amount to the commodity of its assigned price, if any.  Notes:
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
-- - price amounts must be MixedAmounts with exactly one component Amount (or there will be a runtime error)
 | 
					-- - price amounts must be MixedAmounts with exactly one component Amount (or there will be a runtime error)
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
-- - price amounts should be positive, though this is not currently enforced
 | 
					-- - price amounts should be positive, though this is not currently enforced
 | 
				
			||||||
costOfAmount :: Amount -> Amount
 | 
					costOfAmount :: Amount -> Amount
 | 
				
			||||||
costOfAmount a@(Amount _ q price) =
 | 
					costOfAmount a@(Amount _ q price) =
 | 
				
			||||||
@ -186,8 +188,8 @@ showPriceDebug (UnitPrice pa)  = " @ "  ++ showMixedAmountDebug pa
 | 
				
			|||||||
showPriceDebug (TotalPrice pa) = " @@ " ++ showMixedAmountDebug pa
 | 
					showPriceDebug (TotalPrice pa) = " @@ " ++ showMixedAmountDebug pa
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- | Get the string representation of an amount, based on its commodity's
 | 
					-- | Get the string representation of an amount, based on its commodity's
 | 
				
			||||||
-- display settings. Amounts whose string representation would mean zero
 | 
					-- display settings. String representations equivalent to zero are
 | 
				
			||||||
-- are rendered as just "0".
 | 
					-- converted to just \"0\".
 | 
				
			||||||
showAmount :: Amount -> String
 | 
					showAmount :: Amount -> String
 | 
				
			||||||
showAmount (Amount (Commodity {symbol="AUTO"}) _ _) = "" -- can appear in an error message
 | 
					showAmount (Amount (Commodity {symbol="AUTO"}) _ _) = "" -- can appear in an error message
 | 
				
			||||||
showAmount a@(Amount (Commodity {symbol=sym,side=side,spaced=spaced}) _ pri) =
 | 
					showAmount a@(Amount (Commodity {symbol=sym,side=side,spaced=spaced}) _ pri) =
 | 
				
			||||||
@ -354,8 +356,7 @@ setMixedAmountPrecision p (Mixed as) = Mixed $ map (setAmountPrecision p) as
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- | Get the string representation of a mixed amount, showing each of its
 | 
					-- | Get the string representation of a mixed amount, showing each of its
 | 
				
			||||||
-- component amounts with the specified precision, ignoring their
 | 
					-- component amounts with the specified precision, ignoring their
 | 
				
			||||||
-- commoditys' display precision settings. NB a mixed amount can have an
 | 
					-- commoditys' display precision settings.
 | 
				
			||||||
-- empty amounts list in which case it shows as \"\".
 | 
					 | 
				
			||||||
showMixedAmountWithPrecision :: Int -> MixedAmount -> String
 | 
					showMixedAmountWithPrecision :: Int -> MixedAmount -> String
 | 
				
			||||||
showMixedAmountWithPrecision p m =
 | 
					showMixedAmountWithPrecision p m =
 | 
				
			||||||
    vConcatRightAligned $ map (showAmountWithPrecision p) $ amounts $ normaliseMixedAmount m
 | 
					    vConcatRightAligned $ map (showAmountWithPrecision p) $ amounts $ normaliseMixedAmount m
 | 
				
			||||||
 | 
				
			|||||||
@ -69,10 +69,10 @@ data Commodity = Commodity {
 | 
				
			|||||||
      separatorpositions :: [Int]  -- ^ positions of separators, counting leftward from decimal point
 | 
					      separatorpositions :: [Int]  -- ^ positions of separators, counting leftward from decimal point
 | 
				
			||||||
    } deriving (Eq,Ord,Show,Read)
 | 
					    } deriving (Eq,Ord,Show,Read)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- | An amount's price may be written as \@ unit price or \@\@ total price.
 | 
					-- | An amount's price in another commodity may be written as \@ unit
 | 
				
			||||||
-- Note although Price has a MixedAmount, it should hold only
 | 
					-- price or \@\@ total price.  Note although a MixedAmount is used, it
 | 
				
			||||||
-- single-commodity amounts, cf costOfAmount. Moreover, price should always 
 | 
					-- should be in a single commodity, also the amount should be positive;
 | 
				
			||||||
-- be positive, though it is currently not enforced.
 | 
					-- these are not enforced currently.
 | 
				
			||||||
data Price = UnitPrice MixedAmount | TotalPrice MixedAmount
 | 
					data Price = UnitPrice MixedAmount | TotalPrice MixedAmount
 | 
				
			||||||
             deriving (Eq,Ord)
 | 
					             deriving (Eq,Ord)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user