canadian-income-tax
Safe HaskellNone
LanguageHaskell2010

Tax.FDF

Description

Utility functions for dealing with FDF forms

Synopsis

Documentation

type FDFs a = Map a FDF Source #

A collection of FDF forms keyed by an identifier. The identifier type must be a lawful instance of Ord, Read, and Show classes, and its show must be injective and inverse of read.

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 :: forall a. (Eq a, Show a) => a -> Entry a -> Entry a 
Count :: Entry Word 
Date :: Entry Day 
Year :: Entry Int 
Month :: Entry Int 
Province :: Entry Code 
Textual :: Entry Text 
Amount :: Entry (Fixed E2) 
Percent :: Entry (Ratio Integer) 
Checkbox :: Entry Bool 
RadioButton :: forall a. (Eq a, Show a) => [a] -> Entry a 
RadioButtons :: forall a. (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, Ord a, Read a, Show a) => form FieldConst -> (form Maybe -> form Maybe) -> FDFs a -> Either String (FDFs a) 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 :: (Apply form, Traversable form, Ord a, Read a, Show a) => form FieldConst -> FDFs a -> 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, Ord a, Show a) => form FieldConst -> FDFs a -> form Maybe -> Either String (FDFs a) 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, Ord a, Show a) => form FieldConst -> form Maybe -> FDFs a -> Either String (FDFs a) 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 #