canadian-income-tax-2023.0: Canadian income tax calculation
Safe HaskellSafe-Inferred
LanguageHaskell2010

Tax.FDF

Description

Utility functions for dealing with FDF forms

Synopsis

Documentation

type FDFs = Map Text FDF Source #

A collection of FDF forms keyed by a Text identifier

data FieldConst a Source #

A form field path serves to uniquely identify and locate the field inside a form

Constructors

Field 

Fields

NoField 

data Entry a where Source #

The type of a single form field value

Constructors

Constant :: (Eq a, Show a) => a -> Entry a -> Entry a 
Count :: Entry Word 
Date :: Entry Day 
Province :: Entry Code 
Textual :: Entry Text 
Amount :: Entry Centi 
Percent :: Entry Rational 
Checkbox :: Entry Bool 
RadioButton :: (Eq a, Show a) => [a] -> Entry a 
RadioButtons :: (Bounded a, Enum a, Eq a, Show a) => Int -> Int -> Text -> [a] -> Entry a 
Switch :: Text -> Text -> Text -> Entry Bool 
Switch' :: Text -> Entry Bool 

Instances

Instances details
Show a => Show (Entry a) Source # 
Instance details

Defined in Tax.FDF

Methods

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

show :: Entry a -> String #

showList :: [Entry a] -> ShowS #

mapForm :: (Apply form, Traversable form) => form FieldConst -> (form Maybe -> form Maybe) -> FDF -> Either String FDF Source #

Given a form's field paths and a function that modifies a form with optional field values, try to update an FDF with the form. Fail if any of the field paths can't be found in the form.

mapForm2 :: (Apply form1, Apply form2, Traversable form1, Traversable form2) => (form1 FieldConst, form2 FieldConst) -> ((form1 Maybe, form2 Maybe) -> (form1 Maybe, form2 Maybe)) -> (FDF, FDF) -> Either String (FDF, FDF) Source #

Given two forms' field paths and a function that modifies both forms with optional field values, try to update two FDFs with the forms. Fail if any of the field paths can't be found in the forms.

mapForms :: (Apply form, Traversable form) => form FieldConst -> (form Maybe -> form Maybe) -> FDFs -> Either String FDFs Source #

Given the field paths of multiple forms with path heads distinguishing among the forms, and a function that modifies a collection of forms with optional field values, try to update FDFs of the forms. Fail if any of the field paths can't be found in the forms.

load :: (Apply form, Traversable form) => form FieldConst -> FDF -> Either String (form Maybe) Source #

Try to load an FDF into a form with optional values using the given field paths.

loadAll :: forall form. (Apply form, Traversable form) => form FieldConst -> FDFs -> Either String (form Maybe) Source #

Try to load all FDFs into a form with optional values using the given field paths.

store :: (Apply form, Foldable form) => form FieldConst -> FDF -> form Maybe -> Either String FDF Source #

Try to store a form with optional values into the given FDF according to given field paths. Fail if the FDF doesn't contain a field path.

storeAll :: (Apply form, Foldable form) => form FieldConst -> FDFs -> form Maybe -> Either String FDFs Source #

Try to store a form with optional values into the given map of FDFs according to given field paths. The heads of the paths correspond to the map keys. Fail if any of the FDFs doesn't contain a field path, but ignore the path heads not present among the keys of FDFs.

update :: (Apply form, Foldable form) => form FieldConst -> form Maybe -> FDF -> Either String FDF Source #

Try to update the given FDF from the form with optional values according to given form field paths. Fail if the FDF doesn't contain a field path.

updateAll :: (Apply form, Foldable form) => form FieldConst -> form Maybe -> FDFs -> Either String FDFs Source #

Try to update the given map of FDFs from the form with optional values according to given field paths. The heads of the paths correspond to the map keys. Fail if any of the FDFs doesn't contain a field path, but ignore the path heads not present among the keys of FDFs.

formKeys :: Foldable form => form FieldConst -> [[Text]] Source #

The list of all field paths inside a form

within :: Text -> FieldConst x -> FieldConst x Source #

Add a head component to a field path

Orphan instances

MonadFail (Either String) Source # 
Instance details

Methods

fail :: String -> Either String a #