    {-# LANGUAGE OverloadedStrings, FlexibleContexts #-}
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE DeriveGeneric #-}
    -- | Parser for downloaded OFX files.
    --
    -- This parser was written based on the OFX version 1.03
    -- specification, which is available at
    --
    -- <http://www.ofx.net>
    --
    -- It will probably work on earlier versions of OFX without
    -- incident. However, it may or may not not work on newer versions of
    -- OFX, which are XML based (this version of OFX is SGML based.)
    --
    -- It will also parse QFX files, which are OFX files with minor
    -- proprietary additions by Intuit, the maker of Quicken.
    --
    -- An OFX file consists of three parts: the HTTP headers (which this
    -- parser does NOT handle because typically they will not show up in
    -- files downloaded to disk), the OFX headers, and the OFX data. This
    -- parser handles the OFX headers and the OFX data.
    --
    -- The parser in this module simply parses the tags and data into a
    -- tree, which you can manipulate with other functions. Some functions
    -- are provided to find the transactions in the tree and place them
    -- into a 'Transaction' type, which is the data you are most likely
    -- interested in. If you are interested in other data you can query
    -- the 'Tag' tree for what you need.
    --
    -- The @ofx@ package includes two executable files that you can use at
    -- the command line to test the library and see how it works.  The
    -- @renderTransactions@ executable reads an OFX file on standard
    -- input, runs it through the 'prettyRenderTransactions' function, and
    -- prints the result to standard output.  The @renderOfx@ executable
    -- reads an OFX file on standard input, runs it through the
    -- 'prettyRenderOfxFile' function, and prints the result to standard
    -- output.

    module Data.OFX
      ( -- * Error handling
        Err

        -- * The OFX data tree
      , HeaderTag
      , HeaderValue
      , OFXHeader(..)
      , TagName
      , TagData
      , Tag(..)
      , OFXFile(..)

      -- * Manipulating the OFX tag tree
      , find
      , findPath
      , tagData
      , pathData
      , findData

      -- * Extracting specific data
      , fiName
      , creditCardNumber
      , bankAccountNumber
      , accountNumber

      -- * Types to represent specific OFX data
      , Transaction(..)
      , transaction
      , transactions
      , TrnType(..)
      , trnType
      , Payee(..)
      , payee
      , CorrectAction(..)
      , BankAcctTo(..)
      , bankAcctTo
      , CCAcctTo(..)
      , ccAcctTo
      , AcctType(..)
      , acctType
      , CurrencyData(..)
      , currencyData
      , Currency(..)
      , currency
      , OrigCurrency(..)
      , origCurrency

      -- * Running parsers
      , parseOfxFile
      , loadOfxFile
      , parseTransactions
      , loadTransactions
      , prettyRenderOfxFile
      , prettyRenderTransactions

      -- * Parsec parsers
      , ofxFile
      , newline
      , escChar
      , header
      , openingTag
      , closingTag
      , tag
      , date
      , time
      , tzOffset

      -- * Pretty printers
      , pPayee
      , pTransaction
      , pTag
      , pHeader
      , pFile
      , pEither
      , pMaybe
      , pList
      , label
      , pExceptional
      ) where

    --
    -- # Imports
    --

    import Control.Applicative (many, optional, (<|>))
    import Control.Monad (replicateM, (<=<))
    import Data.Data (Data)
    import Data.Maybe (listToMaybe)
    import Data.Monoid ((<>))
    import qualified Data.Monoid as M
    import qualified Data.Time as T
    import Data.Typeable (Typeable)
    import GHC.Generics (Generic)
    import Text.Parsec.String (Parser)
    import Text.Parsec
      ( lookAhead, char, manyTill, anyChar, (<?>), eof,
        try, digit, many1, spaces, string, choice, parse )
    import qualified Text.Parsec as P
    import Text.PrettyPrint
      ( Doc, hang, text, sep, vcat, nest, (<+>), ($$),
        parens, brackets, render )

    --
    -- # Error handling
    --

    -- | Error handling. Errors are indicated with a Left String;
    -- successes with a Right.
    type Err = Either String

    --
    -- # Data types
    --

    -- | Headers consists of simple @tag:value@ pairs; this represents the
    -- tag.
    type HeaderTag = String

    -- | The value in an OFX header.
    type HeaderValue = String

    -- | An OFX file starts with a number of headers, which take the form
    -- @tag:value@ followed by a newline. These are followed by a blank
    -- line.
    data OFXHeader = OFXHeader HeaderTag HeaderValue
      deriving (OFXHeader -> OFXHeader -> Bool
    (OFXHeader -> OFXHeader -> Bool)
    -> (OFXHeader -> OFXHeader -> Bool) -> Eq OFXHeader
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: OFXHeader -> OFXHeader -> Bool
    == :: OFXHeader -> OFXHeader -> Bool
    $c/= :: OFXHeader -> OFXHeader -> Bool
    /= :: OFXHeader -> OFXHeader -> Bool
    Eq, Int -> OFXHeader -> ShowS
    [OFXHeader] -> ShowS
    OFXHeader -> [Char]
    (Int -> OFXHeader -> ShowS)
    -> (OFXHeader -> [Char])
    -> ([OFXHeader] -> ShowS)
    -> Show OFXHeader
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> OFXHeader -> ShowS
    showsPrec :: Int -> OFXHeader -> ShowS
    $cshow :: OFXHeader -> [Char]
    show :: OFXHeader -> [Char]
    $cshowList :: [OFXHeader] -> ShowS
    showList :: [OFXHeader] -> ShowS
    Show, ReadPrec [OFXHeader]
    ReadPrec OFXHeader
    Int -> ReadS OFXHeader
    ReadS [OFXHeader]
    (Int -> ReadS OFXHeader)
    -> ReadS [OFXHeader]
    -> ReadPrec OFXHeader
    -> ReadPrec [OFXHeader]
    -> Read OFXHeader
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS OFXHeader
    readsPrec :: Int -> ReadS OFXHeader
    $creadList :: ReadS [OFXHeader]
    readList :: ReadS [OFXHeader]
    $creadPrec :: ReadPrec OFXHeader
    readPrec :: ReadPrec OFXHeader
    $creadListPrec :: ReadPrec [OFXHeader]
    readListPrec :: ReadPrec [OFXHeader]
    Read, Typeable OFXHeader
    Typeable OFXHeader =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> OFXHeader -> c OFXHeader)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c OFXHeader)
    -> (OFXHeader -> Constr)
    -> (OFXHeader -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c OFXHeader))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OFXHeader))
    -> ((forall b. Data b => b -> b) -> OFXHeader -> OFXHeader)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> OFXHeader -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> OFXHeader -> r)
    -> (forall u. (forall d. Data d => d -> u) -> OFXHeader -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> OFXHeader -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> OFXHeader -> m OFXHeader)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> OFXHeader -> m OFXHeader)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> OFXHeader -> m OFXHeader)
    -> Data OFXHeader
    OFXHeader -> Constr
    OFXHeader -> DataType
    (forall b. Data b => b -> b) -> OFXHeader -> OFXHeader
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> OFXHeader -> u
    forall u. (forall d. Data d => d -> u) -> OFXHeader -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> OFXHeader -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> OFXHeader -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> OFXHeader -> m OFXHeader
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OFXHeader -> m OFXHeader
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c OFXHeader
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OFXHeader -> c OFXHeader
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c OFXHeader)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OFXHeader)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OFXHeader -> c OFXHeader
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OFXHeader -> c OFXHeader
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c OFXHeader
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c OFXHeader
    $ctoConstr :: OFXHeader -> Constr
    toConstr :: OFXHeader -> Constr
    $cdataTypeOf :: OFXHeader -> DataType
    dataTypeOf :: OFXHeader -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c OFXHeader)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c OFXHeader)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OFXHeader)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OFXHeader)
    $cgmapT :: (forall b. Data b => b -> b) -> OFXHeader -> OFXHeader
    gmapT :: (forall b. Data b => b -> b) -> OFXHeader -> OFXHeader
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> OFXHeader -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> OFXHeader -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> OFXHeader -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> OFXHeader -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> OFXHeader -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> OFXHeader -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> OFXHeader -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> OFXHeader -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> OFXHeader -> m OFXHeader
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> OFXHeader -> m OFXHeader
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OFXHeader -> m OFXHeader
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OFXHeader -> m OFXHeader
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OFXHeader -> m OFXHeader
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OFXHeader -> m OFXHeader
    Data, (forall x. OFXHeader -> Rep OFXHeader x)
    -> (forall x. Rep OFXHeader x -> OFXHeader) -> Generic OFXHeader
    forall x. Rep OFXHeader x -> OFXHeader
    forall x. OFXHeader -> Rep OFXHeader x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. OFXHeader -> Rep OFXHeader x
    from :: forall x. OFXHeader -> Rep OFXHeader x
    $cto :: forall x. Rep OFXHeader x -> OFXHeader
    to :: forall x. Rep OFXHeader x -> OFXHeader
    Generic, Typeable)

    -- | The name of an OFX tag
    type TagName = String

    -- | The data accompanying an OFX tag.
    type TagData = String

    -- | The main OFX data consists of a series of tags. OFX 1.03 is SGML,
    -- not XML. This means that opening tags need not have closing
    -- tags. In OFX, a tag either has data and no child elements, or it
    -- has no data and it has child elements.
    data Tag = Tag TagName (Either TagData [Tag])
      deriving (Tag -> Tag -> Bool
    (Tag -> Tag -> Bool) -> (Tag -> Tag -> Bool) -> Eq Tag
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Tag -> Tag -> Bool
    == :: Tag -> Tag -> Bool
    $c/= :: Tag -> Tag -> Bool
    /= :: Tag -> Tag -> Bool
    Eq, Int -> Tag -> ShowS
    [Tag] -> ShowS
    Tag -> [Char]
    (Int -> Tag -> ShowS)
    -> (Tag -> [Char]) -> ([Tag] -> ShowS) -> Show Tag
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Tag -> ShowS
    showsPrec :: Int -> Tag -> ShowS
    $cshow :: Tag -> [Char]
    show :: Tag -> [Char]
    $cshowList :: [Tag] -> ShowS
    showList :: [Tag] -> ShowS
    Show, ReadPrec [Tag]
    ReadPrec Tag
    Int -> ReadS Tag
    ReadS [Tag]
    (Int -> ReadS Tag)
    -> ReadS [Tag] -> ReadPrec Tag -> ReadPrec [Tag] -> Read Tag
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Tag
    readsPrec :: Int -> ReadS Tag
    $creadList :: ReadS [Tag]
    readList :: ReadS [Tag]
    $creadPrec :: ReadPrec Tag
    readPrec :: ReadPrec Tag
    $creadListPrec :: ReadPrec [Tag]
    readListPrec :: ReadPrec [Tag]
    Read, Typeable Tag
    Typeable Tag =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Tag -> c Tag)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Tag)
    -> (Tag -> Constr)
    -> (Tag -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Tag))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Tag))
    -> ((forall b. Data b => b -> b) -> Tag -> Tag)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Tag -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> Tag -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Tag -> m Tag)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Tag -> m Tag)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Tag -> m Tag)
    -> Data Tag
    Tag -> Constr
    Tag -> DataType
    (forall b. Data b => b -> b) -> Tag -> Tag
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Tag -> u
    forall u. (forall d. Data d => d -> u) -> Tag -> [u]
    forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r
    forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Tag
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Tag -> c Tag
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Tag)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Tag)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Tag -> c Tag
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Tag -> c Tag
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Tag
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Tag
    $ctoConstr :: Tag -> Constr
    toConstr :: Tag -> Constr
    $cdataTypeOf :: Tag -> DataType
    dataTypeOf :: Tag -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Tag)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Tag)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Tag)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Tag)
    $cgmapT :: (forall b. Data b => b -> b) -> Tag -> Tag
    gmapT :: (forall b. Data b => b -> b) -> Tag -> Tag
    $cgmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r
    gmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r
    gmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Tag -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Tag -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Tag -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Tag -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    Data, (forall x. Tag -> Rep Tag x)
    -> (forall x. Rep Tag x -> Tag) -> Generic Tag
    forall x. Rep Tag x -> Tag
    forall x. Tag -> Rep Tag x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Tag -> Rep Tag x
    from :: forall x. Tag -> Rep Tag x
    $cto :: forall x. Rep Tag x -> Tag
    to :: forall x. Rep Tag x -> Tag
    Generic, Typeable)

    -- | All the data from an OFX file.
    data OFXFile = OFXFile
      { OFXFile -> [OFXHeader]
    fHeader :: [OFXHeader]

      , OFXFile -> Tag
    fTag :: Tag
      -- ^ All the data will be contained in a root tag with the TagName
      -- @OFX@.

      } deriving (OFXFile -> OFXFile -> Bool
    (OFXFile -> OFXFile -> Bool)
    -> (OFXFile -> OFXFile -> Bool) -> Eq OFXFile
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: OFXFile -> OFXFile -> Bool
    == :: OFXFile -> OFXFile -> Bool
    $c/= :: OFXFile -> OFXFile -> Bool
    /= :: OFXFile -> OFXFile -> Bool
    Eq, Int -> OFXFile -> ShowS
    [OFXFile] -> ShowS
    OFXFile -> [Char]
    (Int -> OFXFile -> ShowS)
    -> (OFXFile -> [Char]) -> ([OFXFile] -> ShowS) -> Show OFXFile
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> OFXFile -> ShowS
    showsPrec :: Int -> OFXFile -> ShowS
    $cshow :: OFXFile -> [Char]
    show :: OFXFile -> [Char]
    $cshowList :: [OFXFile] -> ShowS
    showList :: [OFXFile] -> ShowS
    Show, ReadPrec [OFXFile]
    ReadPrec OFXFile
    Int -> ReadS OFXFile
    ReadS [OFXFile]
    (Int -> ReadS OFXFile)
    -> ReadS [OFXFile]
    -> ReadPrec OFXFile
    -> ReadPrec [OFXFile]
    -> Read OFXFile
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS OFXFile
    readsPrec :: Int -> ReadS OFXFile
    $creadList :: ReadS [OFXFile]
    readList :: ReadS [OFXFile]
    $creadPrec :: ReadPrec OFXFile
    readPrec :: ReadPrec OFXFile
    $creadListPrec :: ReadPrec [OFXFile]
    readListPrec :: ReadPrec [OFXFile]
    Read, Typeable OFXFile
    Typeable OFXFile =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> OFXFile -> c OFXFile)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c OFXFile)
    -> (OFXFile -> Constr)
    -> (OFXFile -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c OFXFile))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OFXFile))
    -> ((forall b. Data b => b -> b) -> OFXFile -> OFXFile)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> OFXFile -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> OFXFile -> r)
    -> (forall u. (forall d. Data d => d -> u) -> OFXFile -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> OFXFile -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> OFXFile -> m OFXFile)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> OFXFile -> m OFXFile)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> OFXFile -> m OFXFile)
    -> Data OFXFile
    OFXFile -> Constr
    OFXFile -> DataType
    (forall b. Data b => b -> b) -> OFXFile -> OFXFile
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> OFXFile -> u
    forall u. (forall d. Data d => d -> u) -> OFXFile -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> OFXFile -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> OFXFile -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> OFXFile -> m OFXFile
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OFXFile -> m OFXFile
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c OFXFile
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OFXFile -> c OFXFile
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c OFXFile)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OFXFile)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OFXFile -> c OFXFile
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OFXFile -> c OFXFile
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c OFXFile
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c OFXFile
    $ctoConstr :: OFXFile -> Constr
    toConstr :: OFXFile -> Constr
    $cdataTypeOf :: OFXFile -> DataType
    dataTypeOf :: OFXFile -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c OFXFile)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c OFXFile)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OFXFile)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OFXFile)
    $cgmapT :: (forall b. Data b => b -> b) -> OFXFile -> OFXFile
    gmapT :: (forall b. Data b => b -> b) -> OFXFile -> OFXFile
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> OFXFile -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> OFXFile -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> OFXFile -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> OFXFile -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> OFXFile -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> OFXFile -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> OFXFile -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> OFXFile -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> OFXFile -> m OFXFile
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> OFXFile -> m OFXFile
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OFXFile -> m OFXFile
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OFXFile -> m OFXFile
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OFXFile -> m OFXFile
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OFXFile -> m OFXFile
    Data, (forall x. OFXFile -> Rep OFXFile x)
    -> (forall x. Rep OFXFile x -> OFXFile) -> Generic OFXFile
    forall x. Rep OFXFile x -> OFXFile
    forall x. OFXFile -> Rep OFXFile x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. OFXFile -> Rep OFXFile x
    from :: forall x. OFXFile -> Rep OFXFile x
    $cto :: forall x. Rep OFXFile x -> OFXFile
    to :: forall x. Rep OFXFile x -> OFXFile
    Generic, Typeable)

    --
    -- # Parsers
    --

    -- | Parses either a UNIX or an MS-DOS newline. According to 1.2.2,
    -- OFX does not contain any white space between tags. However, since I
    -- have seen OFX files that do have whitespace between tags, the
    -- parser makes allowance for this.
    newline :: Parser ()
    newline :: Parser ()
    newline = () () -> ParsecT [Char] () Identity Char -> Parser ()
    forall a b.
    a -> ParsecT [Char] () Identity b -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '\n' Parser () -> Parser () -> Parser ()
    forall a.
    ParsecT [Char] () Identity a
    -> ParsecT [Char] () Identity a -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> () () -> ParsecT [Char] () Identity Char -> Parser ()
    forall a b.
    a -> ParsecT [Char] () Identity b -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ (Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '\r' ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity Char
    forall a b.
    ParsecT [Char] () Identity a
    -> ParsecT [Char] () Identity b -> ParsecT [Char] () Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '\n')
              Parser () -> [Char] -> Parser ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> [Char]
    "newline"

    -- | Parses a character, possibly with an escape sequence. The
    -- greater-than sign, less-than sign, and ampersand must be entered
    -- with escape sequences.
    --
    -- According to OFX spec section 2.3.2.1, ampersands, less-than signs,
    -- and greater-than signs must appear as entities.  However some banks
    -- deliver broken OFX files that do not use entities for ampersands
    -- (and possibly for less-than or greater-than signs too, although I
    -- have not yet observed such behavior.) There is now an error message
    -- that reflects this problem.  Client code can filter the OFX data
    -- for known offenders before passing it to this library.
    escChar :: Parser Char
    escChar :: ParsecT [Char] () Identity Char
    escChar =
      do
        Char
    c <- ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    anyChar
        case Char
    c of
          Char
    '&' -> do
            let mkParser :: (a, [Char]) -> ParsecT s u m a
    mkParser (a
    ch, [Char]
    str) = ParsecT s u m a -> ParsecT s u m a
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (a
    ch a -> ParsecT s u m [Char] -> ParsecT s u m a
    forall a b. a -> ParsecT s u m b -> ParsecT s u m a
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ [Char] -> ParsecT s u m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string [Char]
    str)
            Char
    ent <- [ParsecT [Char] () Identity Char]
    -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice (((Char, [Char]) -> ParsecT [Char] () Identity Char)
    -> [(Char, [Char])] -> [ParsecT [Char] () Identity Char]
    forall a b. (a -> b) -> [a] -> [b]
    map (Char, [Char]) -> ParsecT [Char] () Identity Char
    forall {s} {m :: * -> *} {a} {u}.
    Stream s m Char =>
    (a, [Char]) -> ParsecT s u m a
    mkParser
                    [(Char
    '<', [Char]
    "lt"), (Char
    '>', [Char]
    "gt"), (Char
    '&', [Char]
    "amp")])
                    ParsecT [Char] () Identity Char
    -> [Char] -> ParsecT [Char] () Identity Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> ( [Char]
    "entity (\"lt\", \"gt\", or \"amp\")\n"
                          [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "some banks create broken OFX files. Try\n"
                          [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "removing the ampersands from the file and\n"
                          [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "trying again.")
            Char
    _ <- Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    ';'
            Char -> ParsecT [Char] () Identity Char
    forall a. a -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Char
    ent
          Char
    _ -> Char -> ParsecT [Char] () Identity Char
    forall a. a -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Char
    c
      ParsecT [Char] () Identity Char
    -> [Char] -> ParsecT [Char] () Identity Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> [Char]
    "character"

    header :: Parser OFXHeader
    header :: Parser OFXHeader
    header
      = [Char] -> [Char] -> OFXHeader
    OFXHeader
      ([Char] -> [Char] -> OFXHeader)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity ([Char] -> OFXHeader)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity [Char]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    manyTill ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    anyChar (Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    ':')
      ParsecT [Char] () Identity ([Char] -> OFXHeader)
    -> ParsecT [Char] () Identity (Maybe [Char])
    -> ParsecT [Char] () Identity ([Char] -> OFXHeader)
    forall a b.
    ParsecT [Char] () Identity a
    -> ParsecT [Char] () Identity b -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <*  ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity (Maybe [Char])
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional (ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity [Char]
    forall a.
    ParsecT [Char] () Identity a -> ParsecT [Char] () Identity [a]
    forall (f :: * -> *) a. Alternative f => f a -> f [a]
    many (Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    ' '))
      ParsecT [Char] () Identity ([Char] -> OFXHeader)
    -> ParsecT [Char] () Identity [Char] -> Parser OFXHeader
    forall a b.
    ParsecT [Char] () Identity (a -> b)
    -> ParsecT [Char] () Identity a -> ParsecT [Char] () Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT [Char] () Identity Char
    -> Parser () -> ParsecT [Char] () Identity [Char]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    manyTill ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    anyChar Parser ()
    newline
      Parser OFXHeader -> [Char] -> Parser OFXHeader
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> [Char]
    "OFX header"

    -- | Parses any opening tag. Returns the name of the tag.
    openingTag :: Parser TagName
    openingTag :: ParsecT [Char] () Identity [Char]
    openingTag =
      do
        Char
    _ <- Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '<'
        [Char]
    cs <- ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity [Char]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    manyTill ParsecT [Char] () Identity Char
    escChar (Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '>')
        case [Char]
    cs of
          [] -> [Char] -> ParsecT [Char] () Identity [Char]
    forall a. [Char] -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. MonadFail m => [Char] -> m a
    fail [Char]
    "opening tag with empty name"
          Char
    x:[Char]
    _ ->
            if Char
    x Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == Char
    '/'
            then [Char] -> ParsecT [Char] () Identity [Char]
    forall a. [Char] -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. MonadFail m => [Char] -> m a
    fail [Char]
    "this is a closing tag"
            else [Char] -> ParsecT [Char] () Identity [Char]
    forall a. a -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return [Char]
    cs
      ParsecT [Char] () Identity [Char]
    -> [Char] -> ParsecT [Char] () Identity [Char]
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> [Char]
    "opening tag"

    -- | Parses a closing tag with the given name.
    closingTag :: TagName -> Parser ()
    closingTag :: [Char] -> Parser ()
    closingTag [Char]
    n =
      do
        Char
    _ <- Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '<'
        Char
    _ <- Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '/'
        [Char]
    cs <- ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity [Char]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    manyTill ParsecT [Char] () Identity Char
    escChar (Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '>')
        if [Char]
    cs [Char] -> [Char] -> Bool
    forall a. Eq a => a -> a -> Bool
    == [Char]
    n
          then () -> Parser ()
    forall a. a -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
          else [Char] -> Parser ()
    forall a. [Char] -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. MonadFail m => [Char] -> m a
    fail ([Char] -> Parser ()) -> [Char] -> Parser ()
    forall a b. (a -> b) -> a -> b
    $ [Char]
    "expecting closing tag named " [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    n
                      [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "; saw closing tag named " [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    cs
      Parser () -> [Char] -> Parser ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> [Char]
    "closing tag named " [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    n

    -- | Parses any tag. The tag itself must be followed by at least one
    -- character: either the next tag if this is an aggregate tag, or the
    -- data if this is a data tag. OFX does not allow empty tags.
    --
    -- The OFX spec seems to say that OFX files do not include trailing
    -- newlines after tags or data, but I have seen these newlines in QFX
    -- files, so this parses optional trailing newlines and spaces.
    tag :: Parser Tag
    tag :: Parser Tag
    tag =
      do
        -- try is needed because openingTag will overlap with closingTag
        [Char]
    n <- ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT [Char] () Identity [Char]
    openingTag ParsecT [Char] () Identity [Char]
    -> Parser () -> ParsecT [Char] () Identity [Char]
    forall a b.
    ParsecT [Char] () Identity a
    -> ParsecT [Char] () Identity b -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parser ()
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
    spaces)
        [Tag]
    children <- Parser Tag -> ParsecT [Char] () Identity [Tag]
    forall a.
    ParsecT [Char] () Identity a -> ParsecT [Char] () Identity [a]
    forall (f :: * -> *) a. Alternative f => f a -> f [a]
    many Parser Tag
    tag
        if [Tag] -> Bool
    forall a. [a] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [Tag]
    children
          then [Char] -> Either [Char] [Tag] -> Tag
    Tag [Char]
    n (Either [Char] [Tag] -> Tag)
    -> ([Char] -> Either [Char] [Tag]) -> [Char] -> Tag
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Either [Char] [Tag]
    forall a b. a -> Either a b
    Left
               ([Char] -> Tag) -> ParsecT [Char] () Identity [Char] -> Parser Tag
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT [Char] () Identity Char
    -> Parser () -> ParsecT [Char] () Identity [Char]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    manyTill ParsecT [Char] () Identity Char
    escChar
                    (Parser ()
    forall s (m :: * -> *) t u.
    (Stream s m t, Show t) =>
    ParsecT s u m ()
    eof Parser () -> Parser () -> Parser ()
    forall a.
    ParsecT [Char] () Identity a
    -> ParsecT [Char] () Identity a -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Parser () -> Parser ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead (() () -> ParsecT [Char] () Identity Char -> Parser ()
    forall a b.
    a -> ParsecT [Char] () Identity b -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '<') Parser () -> Parser () -> Parser ()
    forall a.
    ParsecT [Char] () Identity a
    -> ParsecT [Char] () Identity a -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Parser ()
    newline)
               Parser Tag -> Parser () -> Parser Tag
    forall a b.
    ParsecT [Char] () Identity a
    -> ParsecT [Char] () Identity b -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parser ()
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
    spaces
               Parser Tag -> ParsecT [Char] () Identity (Maybe ()) -> Parser Tag
    forall a b.
    ParsecT [Char] () Identity a
    -> ParsecT [Char] () Identity b -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parser () -> ParsecT [Char] () Identity (Maybe ())
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional (Parser () -> Parser ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ([Char] -> Parser ()
    closingTag [Char]
    n))
               Parser Tag -> Parser () -> Parser Tag
    forall a b.
    ParsecT [Char] () Identity a
    -> ParsecT [Char] () Identity b -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parser ()
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
    spaces
          else [Char] -> Either [Char] [Tag] -> Tag
    Tag [Char]
    n ([Tag] -> Either [Char] [Tag]
    forall a b. b -> Either a b
    Right [Tag]
    children) Tag -> Parser () -> Parser Tag
    forall a b.
    a -> ParsecT [Char] () Identity b -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Parser ()
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
    spaces Parser Tag -> Parser () -> Parser Tag
    forall a b.
    ParsecT [Char] () Identity a
    -> ParsecT [Char] () Identity b -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* [Char] -> Parser ()
    closingTag [Char]
    n
                                      Parser Tag -> Parser () -> Parser Tag
    forall a b.
    ParsecT [Char] () Identity a
    -> ParsecT [Char] () Identity b -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parser ()
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
    spaces
      Parser Tag -> [Char] -> Parser Tag
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> [Char]
    "OFX tag"

    -- | Parses an entire OFX file, including headers.
    ofxFile :: Parser OFXFile
    ofxFile :: Parser OFXFile
    ofxFile
      = [OFXHeader] -> Tag -> OFXFile
    OFXFile
      ([OFXHeader] -> Tag -> OFXFile)
    -> ParsecT [Char] () Identity [OFXHeader]
    -> ParsecT [Char] () Identity (Tag -> OFXFile)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser OFXHeader
    -> Parser () -> ParsecT [Char] () Identity [OFXHeader]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    manyTill Parser OFXHeader
    header Parser ()
    newline
      ParsecT [Char] () Identity (Tag -> OFXFile)
    -> Parser Tag -> Parser OFXFile
    forall a b.
    ParsecT [Char] () Identity (a -> b)
    -> ParsecT [Char] () Identity a -> ParsecT [Char] () Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser Tag
    tag
      Parser OFXFile -> Parser () -> Parser OFXFile
    forall a b.
    ParsecT [Char] () Identity a
    -> ParsecT [Char] () Identity b -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parser ()
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
    spaces
      Parser OFXFile -> Parser () -> Parser OFXFile
    forall a b.
    ParsecT [Char] () Identity a
    -> ParsecT [Char] () Identity b -> ParsecT [Char] () Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parser ()
    forall s (m :: * -> *) t u.
    (Stream s m t, Show t) =>
    ParsecT s u m ()
    eof
      Parser OFXFile -> [Char] -> Parser OFXFile
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> [Char]
    "OFX file"

    -- | Parses an OFX date; provides an error message if the parse fails.
    parseDate :: String -> Err T.ZonedTime
    parseDate :: [Char] -> Err ZonedTime
    parseDate [Char]
    s = case Parsec [Char] () ZonedTime
    -> [Char] -> [Char] -> Either ParseError ZonedTime
    forall s t a.
    Stream s Identity t =>
    Parsec s () a -> [Char] -> s -> Either ParseError a
    P.parse Parsec [Char] () ZonedTime
    date [Char]
    "" [Char]
    s of
      Left ParseError
    e -> [Char] -> Err ZonedTime
    forall a b. a -> Either a b
    Left ([Char] -> Err ZonedTime) -> [Char] -> Err ZonedTime
    forall a b. (a -> b) -> a -> b
    $ [Char]
    "could not parse date: " [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    s [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    ": "
                [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ParseError -> [Char]
    forall a. Show a => a -> [Char]
    show ParseError
    e
      Right ZonedTime
    g -> ZonedTime -> Err ZonedTime
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ZonedTime
    g

    -- | Parses an OFX date. Fails if the date is not valid or if there is
    -- no date to be parsed.
    date :: Parser T.ZonedTime
    date :: Parsec [Char] () ZonedTime
    date =
      do
        Year
    ys <- ([Char] -> Year)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity Year
    forall a b.
    (a -> b)
    -> ParsecT [Char] () Identity a -> ParsecT [Char] () Identity b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Char] -> Year
    forall a. Read a => [Char] -> a
    read (ParsecT [Char] () Identity [Char]
     -> ParsecT [Char] () Identity Year)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity Year
    forall a b. (a -> b) -> a -> b
    $ Int
    -> ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity [Char]
    forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
    replicateM Int
    4 ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    digit
        Int
    ms <- ([Char] -> Int)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity Int
    forall a b.
    (a -> b)
    -> ParsecT [Char] () Identity a -> ParsecT [Char] () Identity b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Char] -> Int
    forall a. Read a => [Char] -> a
    read (ParsecT [Char] () Identity [Char]
     -> ParsecT [Char] () Identity Int)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity Int
    forall a b. (a -> b) -> a -> b
    $ Int
    -> ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity [Char]
    forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
    replicateM Int
    2 ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    digit
        Int
    ds <- ([Char] -> Int)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity Int
    forall a b.
    (a -> b)
    -> ParsecT [Char] () Identity a -> ParsecT [Char] () Identity b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Char] -> Int
    forall a. Read a => [Char] -> a
    read (ParsecT [Char] () Identity [Char]
     -> ParsecT [Char] () Identity Int)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity Int
    forall a b. (a -> b) -> a -> b
    $ Int
    -> ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity [Char]
    forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
    replicateM Int
    2 ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    digit
        Day
    day <- case Year -> Int -> Int -> Maybe Day
    T.fromGregorianValid Year
    ys Int
    ms Int
    ds of
          Maybe Day
    Nothing -> [Char] -> ParsecT [Char] () Identity Day
    forall a. [Char] -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. MonadFail m => [Char] -> m a
    fail ([Char] -> ParsecT [Char] () Identity Day)
    -> [Char] -> ParsecT [Char] () Identity Day
    forall a b. (a -> b) -> a -> b
    $ [Char]
    "invalid date: " [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Year -> [Char]
    forall a. Show a => a -> [Char]
    show Year
    ys
                            [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "-" [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Int -> [Char]
    forall a. Show a => a -> [Char]
    show Int
    ms [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "-" [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Int -> [Char]
    forall a. Show a => a -> [Char]
    show Int
    ds
          Just Day
    d -> Day -> ParsecT [Char] () Identity Day
    forall a. a -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Day
    d
        Maybe (TimeOfDay, TimeZone)
    mayTime <- ParsecT [Char] () Identity (TimeOfDay, TimeZone)
    -> ParsecT [Char] () Identity (Maybe (TimeOfDay, TimeZone))
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional ParsecT [Char] () Identity (TimeOfDay, TimeZone)
    time
        case Maybe (TimeOfDay, TimeZone)
    mayTime of
          Maybe (TimeOfDay, TimeZone)
    Nothing ->
            let localTime :: LocalTime
    localTime = Day -> TimeOfDay -> LocalTime
    T.LocalTime Day
    day TimeOfDay
    T.midnight
            in ZonedTime -> Parsec [Char] () ZonedTime
    forall a. a -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (ZonedTime -> Parsec [Char] () ZonedTime)
    -> ZonedTime -> Parsec [Char] () ZonedTime
    forall a b. (a -> b) -> a -> b
    $ LocalTime -> TimeZone -> ZonedTime
    T.ZonedTime LocalTime
    localTime TimeZone
    T.utc
          Just (TimeOfDay
    t, TimeZone
    z) -> ZonedTime -> Parsec [Char] () ZonedTime
    forall a. a -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (ZonedTime -> Parsec [Char] () ZonedTime)
    -> ZonedTime -> Parsec [Char] () ZonedTime
    forall a b. (a -> b) -> a -> b
    $ LocalTime -> TimeZone -> ZonedTime
    T.ZonedTime (Day -> TimeOfDay -> LocalTime
    T.LocalTime Day
    day TimeOfDay
    t) TimeZone
    z
      Parsec [Char] () ZonedTime -> [Char] -> Parsec [Char] () ZonedTime
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> [Char]
    "date"

    -- | Parses an OFX time. Fails if the time is not valid or if there is
    -- no time to parse. Fails if there is no time to parse; however, if
    -- there is a time but no zone, returns the time and UTC for the zone.
    time :: Parser (T.TimeOfDay, T.TimeZone)
    time :: ParsecT [Char] () Identity (TimeOfDay, TimeZone)
    time =
      do
        Int
    h <- ([Char] -> Int)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity Int
    forall a b.
    (a -> b)
    -> ParsecT [Char] () Identity a -> ParsecT [Char] () Identity b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Char] -> Int
    forall a. Read a => [Char] -> a
    read (ParsecT [Char] () Identity [Char]
     -> ParsecT [Char] () Identity Int)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity Int
    forall a b. (a -> b) -> a -> b
    $ Int
    -> ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity [Char]
    forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
    replicateM Int
    2 ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    digit
        Int
    m <- ([Char] -> Int)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity Int
    forall a b.
    (a -> b)
    -> ParsecT [Char] () Identity a -> ParsecT [Char] () Identity b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Char] -> Int
    forall a. Read a => [Char] -> a
    read (ParsecT [Char] () Identity [Char]
     -> ParsecT [Char] () Identity Int)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity Int
    forall a b. (a -> b) -> a -> b
    $ Int
    -> ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity [Char]
    forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
    replicateM Int
    2 ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    digit
        Pico
    s <- ([Char] -> Pico)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity Pico
    forall a b.
    (a -> b)
    -> ParsecT [Char] () Identity a -> ParsecT [Char] () Identity b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Char] -> Pico
    forall a. Read a => [Char] -> a
    read (ParsecT [Char] () Identity [Char]
     -> ParsecT [Char] () Identity Pico)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity Pico
    forall a b. (a -> b) -> a -> b
    $ Int
    -> ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity [Char]
    forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
    replicateM Int
    2 ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    digit
        (Pico
    milli, TimeZone
    tz) <- do
          Maybe Char
    mayDot <- ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity (Maybe Char)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional (Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '.')
          case Maybe Char
    mayDot of
            Maybe Char
    Nothing -> (Pico, TimeZone) -> ParsecT [Char] () Identity (Pico, TimeZone)
    forall a. a -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Pico
    0, TimeZone
    T.utc)
            Just Char
    _ -> do
              Pico
    mil <- ([Char] -> Pico)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity Pico
    forall a b.
    (a -> b)
    -> ParsecT [Char] () Identity a -> ParsecT [Char] () Identity b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((Pico -> Pico -> Pico
    forall a. Fractional a => a -> a -> a
    / Pico
    1000) (Pico -> Pico) -> ([Char] -> Pico) -> [Char] -> Pico
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Pico
    forall a. Read a => [Char] -> a
    read) (ParsecT [Char] () Identity [Char]
     -> ParsecT [Char] () Identity Pico)
    -> ParsecT [Char] () Identity [Char]
    -> ParsecT [Char] () Identity Pico
    forall a b. (a -> b) -> a -> b
    $ Int
    -> ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity [Char]
    forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
    replicateM Int
    3 ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    digit
              Maybe TimeZone
    mayTz <- ParsecT [Char] () Identity TimeZone
    -> ParsecT [Char] () Identity (Maybe TimeZone)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional ParsecT [Char] () Identity TimeZone
    tzOffset
              case Maybe TimeZone
    mayTz of
                Maybe TimeZone
    Nothing -> (Pico, TimeZone) -> ParsecT [Char] () Identity (Pico, TimeZone)
    forall a. a -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Pico
    mil, TimeZone
    T.utc)
                Just TimeZone
    t -> (Pico, TimeZone) -> ParsecT [Char] () Identity (Pico, TimeZone)
    forall a. a -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Pico
    mil, TimeZone
    t)
        let sec :: Pico
    sec = Pico
    s Pico -> Pico -> Pico
    forall a. Num a => a -> a -> a
    + Pico
    milli
        (TimeOfDay, TimeZone)
    -> ParsecT [Char] () Identity (TimeOfDay, TimeZone)
    forall a. a -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Int -> Int -> Pico -> TimeOfDay
    T.TimeOfDay Int
    h Int
    m Pico
    sec, TimeZone
    tz)
      ParsecT [Char] () Identity (TimeOfDay, TimeZone)
    -> [Char] -> ParsecT [Char] () Identity (TimeOfDay, TimeZone)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> [Char]
    "time"

    -- | Parses a time zone offset. Fails if there is no time zone offset
    -- to parse.
    tzOffset :: Parser T.TimeZone
    tzOffset :: ParsecT [Char] () Identity TimeZone
    tzOffset =
      do
        Char
    _ <- Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '['
        Int -> Int
    sn <- ParsecT [Char] () Identity (Int -> Int)
    forall {u}. ParsecT [Char] u Identity (Int -> Int)
    parseSign
        [Char]
    whole <- ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity [Char]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    digit
        Maybe Char
    mayDot <- ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity (Maybe Char)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional (Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '.')
        [Char]
    frac <- case Maybe Char
    mayDot of
          Maybe Char
    Nothing -> [Char] -> ParsecT [Char] () Identity [Char]
    forall a. a -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return [Char]
    "0"
          Just Char
    _ -> ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity [Char]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    digit
        Maybe Char
    mayColon <- ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity (Maybe Char)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional (Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    ':')
        [Char]
    name <- case Maybe Char
    mayColon of
          Maybe Char
    Nothing -> [Char] -> ParsecT [Char] () Identity [Char]
    forall a. a -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return [Char]
    ""
          Just Char
    _ -> ParsecT [Char] () Identity Char
    -> ParsecT [Char] () Identity [Char]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    P.letter
        Char
    _ <- Char -> ParsecT [Char] () Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    ']'
        let off :: Int
    off = Int -> Int
    sn (Int -> Int) -> Int -> Int
    forall a b. (a -> b) -> a -> b
    $ Double -> Int
    forall b. Integral b => Double -> b
    forall a b. (RealFrac a, Integral b) => a -> b
    round (([Char] -> Double
    forall a. Read a => [Char] -> a
    read ([Char]
    whole [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "." [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    frac))
                                    Double -> Double -> Double
    forall a. Num a => a -> a -> a
    * (Double
    60 :: Double))
        TimeZone -> ParsecT [Char] () Identity TimeZone
    forall a. a -> ParsecT [Char] () Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (TimeZone -> ParsecT [Char] () Identity TimeZone)
    -> TimeZone -> ParsecT [Char] () Identity TimeZone
    forall a b. (a -> b) -> a -> b
    $ Int -> Bool -> [Char] -> TimeZone
    T.TimeZone Int
    off Bool
    False [Char]
    name
      ParsecT [Char] () Identity TimeZone
    -> [Char] -> ParsecT [Char] () Identity TimeZone
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> [Char]
    "time zone offset"
      where
        parseSign :: ParsecT [Char] u Identity (Int -> Int)
    parseSign = do
          Maybe Char
    mayMinus <- ParsecT [Char] u Identity Char
    -> ParsecT [Char] u Identity (Maybe Char)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional (Char -> ParsecT [Char] u Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '-')
          case Maybe Char
    mayMinus of
            Maybe Char
    Nothing -> do
              Maybe Char
    mayPlus <- ParsecT [Char] u Identity Char
    -> ParsecT [Char] u Identity (Maybe Char)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional (Char -> ParsecT [Char] u Identity Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '+')
              (Int -> Int) -> ParsecT [Char] u Identity (Int -> Int)
    forall a. a -> ParsecT [Char] u Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ((Int -> Int) -> ParsecT [Char] u Identity (Int -> Int))
    -> (Int -> Int) -> ParsecT [Char] u Identity (Int -> Int)
    forall a b. (a -> b) -> a -> b
    $ case Maybe Char
    mayPlus of
                Maybe Char
    Nothing -> Int -> Int
    forall a. a -> a
    id
                Just Char
    _ -> Int -> Int
    forall a. Num a => a -> a
    negate
            Just Char
    _ -> (Int -> Int) -> ParsecT [Char] u Identity (Int -> Int)
    forall a. a -> ParsecT [Char] u Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Int -> Int
    forall a. Num a => a -> a
    negate

    --
    -- # Manipulating trees of tags
    --

    -- | Finds child tags with the given name. When a tag is found, that
    -- tag is not searched for further children with the same name.
    find :: TagName -> Tag -> [Tag]
    find :: [Char] -> Tag -> [Tag]
    find [Char]
    n t :: Tag
    t@(Tag [Char]
    x Either [Char] [Tag]
    p)
      | [Char]
    n [Char] -> [Char] -> Bool
    forall a. Eq a => a -> a -> Bool
    == [Char]
    x = [Tag
    t]
      | Bool
    otherwise = case Either [Char] [Tag]
    p of
          Left [Char]
    _ -> []
          Right [Tag]
    ts -> (Tag -> [Tag]) -> [Tag] -> [Tag]
    forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
    concatMap ([Char] -> Tag -> [Tag]
    find [Char]
    n) [Tag]
    ts

    -- | Descends through a tree of tags to find a tag at a specific
    -- location in the tree. Fails if any part of the search fails. For
    -- example, to find the financial institution ORG tag, where @t@ is
    -- the root @OFX@ tag:
    --
    -- > findPath ["SIGNONMSGSRSV1", "SONRS", "FI", "ORG"] t

    findPath :: [TagName] -> Tag -> Maybe Tag
    findPath :: [[Char]] -> Tag -> Maybe Tag
    findPath [] Tag
    t = Tag -> Maybe Tag
    forall a. a -> Maybe a
    Just Tag
    t
    findPath ([Char]
    n:[[Char]]
    ns) Tag
    t = case [Tag] -> Maybe Tag
    forall a. [a] -> Maybe a
    listToMaybe ([Char] -> Tag -> [Tag]
    find [Char]
    n Tag
    t) of
      Maybe Tag
    Nothing -> Maybe Tag
    forall a. Maybe a
    Nothing
      Just Tag
    r -> [[Char]] -> Tag -> Maybe Tag
    findPath [[Char]]
    ns Tag
    r

    -- | Gets the data from a tag, if it is a tag with data.
    tagData :: Tag -> Maybe TagData
    tagData :: Tag -> Maybe [Char]
    tagData (Tag [Char]
    _ Either [Char] [Tag]
    ei) = ([Char] -> Maybe [Char])
    -> ([Tag] -> Maybe [Char]) -> Either [Char] [Tag] -> Maybe [Char]
    forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
    either [Char] -> Maybe [Char]
    forall a. a -> Maybe a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe [Char] -> [Tag] -> Maybe [Char]
    forall a b. a -> b -> a
    const Maybe [Char]
    forall a. Maybe a
    Nothing) Either [Char] [Tag]
    ei

    -- | Goes to a certain path in the tag hierarchy and pulls the
    -- requested data, if the tag is present and it is a data tag.  For
    -- example, to get the name of the financial institution:
    --
    -- > pathData ["SIGNONMSGSRSV1", "SONRS", "FI", "ORG"] f
    pathData :: [TagName] -> OFXFile -> Maybe TagData
    pathData :: [[Char]] -> OFXFile -> Maybe [Char]
    pathData [[Char]]
    p (OFXFile [OFXHeader]
    _ Tag
    t) = [[Char]] -> Tag -> Maybe Tag
    findPath [[Char]]
    p Tag
    t Maybe Tag -> (Tag -> Maybe [Char]) -> Maybe [Char]
    forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Tag -> Maybe [Char]
    tagData

    -- | Gets the name of the financial institution from the FI tag, if
    -- available. The OFX spec does not require this tag to be present.
    fiName :: OFXFile -> Maybe TagData
    fiName :: OFXFile -> Maybe [Char]
    fiName = [[Char]] -> OFXFile -> Maybe [Char]
    pathData [[Char]
    "SIGNONMSGSRSV1", [Char]
    "SONRS", [Char]
    "FI", [Char]
    "ORG"]

    -- | Gets the credit card number, if available. The OFX spec does not
    -- require this tag to be present.
    creditCardNumber :: OFXFile -> Maybe TagData
    creditCardNumber :: OFXFile -> Maybe [Char]
    creditCardNumber =
      [[Char]] -> OFXFile -> Maybe [Char]
    pathData [ [Char]
    "CREDITCARDMSGSRSV1", [Char]
    "CCSTMTTRNRS", [Char]
    "CCSTMTRS",
                 [Char]
    "CCACCTFROM", [Char]
    "ACCTID" ]

    -- | Gets the bank account number, if available. The OFX spec does not
    -- require this tag to be present.
    bankAccountNumber :: OFXFile -> Maybe TagData
    bankAccountNumber :: OFXFile -> Maybe [Char]
    bankAccountNumber =
      [[Char]] -> OFXFile -> Maybe [Char]
    pathData [ [Char]
    "BANKMSGSRSV1", [Char]
    "STMTTRNRS", [Char]
    "STMTRS",
                 [Char]
    "BANKACCTFROM", [Char]
    "ACCTID" ]

    -- | Gets either the credit card or bank account number, if available.
    accountNumber :: OFXFile -> Maybe TagData
    accountNumber :: OFXFile -> Maybe [Char]
    accountNumber OFXFile
    f = OFXFile -> Maybe [Char]
    creditCardNumber OFXFile
    f Maybe [Char] -> Maybe [Char] -> Maybe [Char]
    forall a. Maybe a -> Maybe a -> Maybe a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> OFXFile -> Maybe [Char]
    bankAccountNumber OFXFile
    f

    -- | Finds the first tag (either this tag or any children) that has
    -- the given name and that is a data tag (not an aggregate tag.) If no
    -- data tag with the given name is found, returns Nothing.
    findData :: TagName -> Tag -> Maybe TagData
    findData :: [Char] -> Tag -> Maybe [Char]
    findData [Char]
    n (Tag [Char]
    tn Either [Char] [Tag]
    e) = case Either [Char] [Tag]
    e of
      Left [Char]
    d -> if [Char]
    tn [Char] -> [Char] -> Bool
    forall a. Eq a => a -> a -> Bool
    == [Char]
    n then [Char] -> Maybe [Char]
    forall a. a -> Maybe a
    Just [Char]
    d else Maybe [Char]
    forall a. Maybe a
    Nothing
      Right [Tag]
    ts -> First [Char] -> Maybe [Char]
    forall a. First a -> Maybe a
    M.getFirst (First [Char] -> Maybe [Char])
    -> ([Tag] -> First [Char]) -> [Tag] -> Maybe [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [First [Char]] -> First [Char]
    forall a. Monoid a => [a] -> a
    M.mconcat ([First [Char]] -> First [Char])
    -> ([Tag] -> [First [Char]]) -> [Tag] -> First [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    .  (Maybe [Char] -> First [Char]) -> [Maybe [Char]] -> [First [Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map Maybe [Char] -> First [Char]
    forall a. Maybe a -> First a
    M.First
                  ([Maybe [Char]] -> [First [Char]])
    -> ([Tag] -> [Maybe [Char]]) -> [Tag] -> [First [Char]]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Tag -> Maybe [Char]) -> [Tag] -> [Maybe [Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char] -> Tag -> Maybe [Char]
    findData [Char]
    n) ([Tag] -> Maybe [Char]) -> [Tag] -> Maybe [Char]
    forall a b. (a -> b) -> a -> b
    $ [Tag]
    ts

    -- | Finds the first tag (either this tag or any children) that has
    -- the given name and that is a data tag. Gives an error message if
    -- the tag is not found.
    required :: TagName -> Tag -> Err TagData
    required :: [Char] -> Tag -> Err [Char]
    required [Char]
    n Tag
    t = case [Char] -> Tag -> Maybe [Char]
    findData [Char]
    n Tag
    t of
      Maybe [Char]
    Nothing -> [Char] -> Err [Char]
    forall a b. a -> Either a b
    Left ([Char] -> Err [Char]) -> [Char] -> Err [Char]
    forall a b. (a -> b) -> a -> b
    $ [Char]
    "required tag missing: " [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    n
      Just [Char]
    r -> [Char] -> Err [Char]
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return [Char]
    r

    --
    -- # OFX data
    --

    -- | OFX transaction types. These are used in STMTTRN aggregates, see
    -- OFX spec section 11.4.2.3.1.1.
    data TrnType
      = TCREDIT
      | TDEBIT

      | TINT
      -- ^ Interest earned or paid (which it is depends on sign of amount)

      | TDIV
      -- ^ Dividend

      | TFEE
      | TSRVCHG

      | TDEP
      -- ^ Deposit

      | TATM
      -- ^ ATM debit or credit (which it is depends on sign of amount)

      | TPOS
      -- ^ Point of sale debit or credit (which it is depends on sign of
      -- amount)

      | TXFER
      -- ^ Transfer

      | TCHECK
      | TPAYMENT
      -- ^ Electronic payment

      | TCASH
      -- ^ Cash withdrawal

      | TDIRECTDEP
      -- ^ Direct deposit

      | TDIRECTDEBIT
      -- ^ Merchant initiated debit

      | TREPEATPMT
      -- ^ Repeating payment / standing order

      | TOTHER
      deriving (TrnType -> TrnType -> Bool
    (TrnType -> TrnType -> Bool)
    -> (TrnType -> TrnType -> Bool) -> Eq TrnType
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TrnType -> TrnType -> Bool
    == :: TrnType -> TrnType -> Bool
    $c/= :: TrnType -> TrnType -> Bool
    /= :: TrnType -> TrnType -> Bool
    Eq, Eq TrnType
    Eq TrnType =>
    (TrnType -> TrnType -> Ordering)
    -> (TrnType -> TrnType -> Bool)
    -> (TrnType -> TrnType -> Bool)
    -> (TrnType -> TrnType -> Bool)
    -> (TrnType -> TrnType -> Bool)
    -> (TrnType -> TrnType -> TrnType)
    -> (TrnType -> TrnType -> TrnType)
    -> Ord TrnType
    TrnType -> TrnType -> Bool
    TrnType -> TrnType -> Ordering
    TrnType -> TrnType -> TrnType
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: TrnType -> TrnType -> Ordering
    compare :: TrnType -> TrnType -> Ordering
    $c< :: TrnType -> TrnType -> Bool
    < :: TrnType -> TrnType -> Bool
    $c<= :: TrnType -> TrnType -> Bool
    <= :: TrnType -> TrnType -> Bool
    $c> :: TrnType -> TrnType -> Bool
    > :: TrnType -> TrnType -> Bool
    $c>= :: TrnType -> TrnType -> Bool
    >= :: TrnType -> TrnType -> Bool
    $cmax :: TrnType -> TrnType -> TrnType
    max :: TrnType -> TrnType -> TrnType
    $cmin :: TrnType -> TrnType -> TrnType
    min :: TrnType -> TrnType -> TrnType
    Ord, Int -> TrnType -> ShowS
    [TrnType] -> ShowS
    TrnType -> [Char]
    (Int -> TrnType -> ShowS)
    -> (TrnType -> [Char]) -> ([TrnType] -> ShowS) -> Show TrnType
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> TrnType -> ShowS
    showsPrec :: Int -> TrnType -> ShowS
    $cshow :: TrnType -> [Char]
    show :: TrnType -> [Char]
    $cshowList :: [TrnType] -> ShowS
    showList :: [TrnType] -> ShowS
    Show, ReadPrec [TrnType]
    ReadPrec TrnType
    Int -> ReadS TrnType
    ReadS [TrnType]
    (Int -> ReadS TrnType)
    -> ReadS [TrnType]
    -> ReadPrec TrnType
    -> ReadPrec [TrnType]
    -> Read TrnType
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS TrnType
    readsPrec :: Int -> ReadS TrnType
    $creadList :: ReadS [TrnType]
    readList :: ReadS [TrnType]
    $creadPrec :: ReadPrec TrnType
    readPrec :: ReadPrec TrnType
    $creadListPrec :: ReadPrec [TrnType]
    readListPrec :: ReadPrec [TrnType]
    Read, Typeable TrnType
    Typeable TrnType =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> TrnType -> c TrnType)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c TrnType)
    -> (TrnType -> Constr)
    -> (TrnType -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c TrnType))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TrnType))
    -> ((forall b. Data b => b -> b) -> TrnType -> TrnType)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> TrnType -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> TrnType -> r)
    -> (forall u. (forall d. Data d => d -> u) -> TrnType -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> TrnType -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> TrnType -> m TrnType)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> TrnType -> m TrnType)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> TrnType -> m TrnType)
    -> Data TrnType
    TrnType -> Constr
    TrnType -> DataType
    (forall b. Data b => b -> b) -> TrnType -> TrnType
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> TrnType -> u
    forall u. (forall d. Data d => d -> u) -> TrnType -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TrnType -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TrnType -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TrnType -> m TrnType
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TrnType -> m TrnType
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TrnType
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TrnType -> c TrnType
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TrnType)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TrnType)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TrnType -> c TrnType
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TrnType -> c TrnType
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TrnType
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TrnType
    $ctoConstr :: TrnType -> Constr
    toConstr :: TrnType -> Constr
    $cdataTypeOf :: TrnType -> DataType
    dataTypeOf :: TrnType -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TrnType)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TrnType)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TrnType)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TrnType)
    $cgmapT :: (forall b. Data b => b -> b) -> TrnType -> TrnType
    gmapT :: (forall b. Data b => b -> b) -> TrnType -> TrnType
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TrnType -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TrnType -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TrnType -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TrnType -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> TrnType -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> TrnType -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TrnType -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TrnType -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TrnType -> m TrnType
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TrnType -> m TrnType
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TrnType -> m TrnType
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TrnType -> m TrnType
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TrnType -> m TrnType
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TrnType -> m TrnType
    Data, (forall x. TrnType -> Rep TrnType x)
    -> (forall x. Rep TrnType x -> TrnType) -> Generic TrnType
    forall x. Rep TrnType x -> TrnType
    forall x. TrnType -> Rep TrnType x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. TrnType -> Rep TrnType x
    from :: forall x. TrnType -> Rep TrnType x
    $cto :: forall x. Rep TrnType x -> TrnType
    to :: forall x. Rep TrnType x -> TrnType
    Generic, Typeable)

    -- | A single STMTTRN, see OFX spec section 11.4.2.3.1. This is most
    -- likely what you are interested in after downloading a statement
    -- from a bank.
    data Transaction = Transaction
      { Transaction -> TrnType
    txTRNTYPE :: TrnType
        -- ^ Transaction type

      , Transaction -> ZonedTime
    txDTPOSTED :: T.ZonedTime
        -- ^ Date transaction was posted to account

      , Transaction -> Maybe ZonedTime
    txDTUSER :: Maybe T.ZonedTime
        -- ^ Date user initiated transaction, if known

      , Transaction -> Maybe ZonedTime
    txDTAVAIL :: Maybe T.ZonedTime
        -- ^ Date funds are available

      , Transaction -> [Char]
    txTRNAMT :: String
        -- ^ Amount of transaction. This is left as the string that was
        -- originally in the download. That means the transaction may
        -- include a plus or minus sign (no sign is the same as a plus
        -- sign.) According to section 3.2.9.2, amounts are always signed
        -- from the perspective of the customer.
        --
        -- Typically negative amounts:
        --
        -- * Investment buy amount, investment sell quantity
        --
        -- * Bank statement debit amounts, checks, fees
        --
        -- * Credit card purchases
        --
        -- * Margin balance (unless the institution owes the client money)
        --
        -- Typically positive amounts:
        --
        -- * Investment sell amount, investment buy quantity
        --
        -- * Bank statement credits
        --
        -- * Credit card payments
        --
        -- * Ledger balance (unless the account is overdrawn)
        --
        -- Formats for amounts are described in 3.2.9.1. If there is no
        -- decimal point, there is an implied decimal point at the end of
        -- the value. Trailing and leading spaces \"should\" be
        -- stripped. Positive or minus is indicated with a leading sign; a
        -- plus sign is assumed if there is no sign.
        --
        -- An amount has a maximum of 32 alphanumeric characters,
        -- including digits and punctuation.
        --
        -- The radix point is indicated with either a period or a
        -- comma. Amounts \"should\" not include any digit grouping
        -- characters.

        , Transaction -> [Char]
    txFITID :: String
        -- ^ Transaction ID issued by financial institution. Used to
        -- detect duplicate downloads.

        , Transaction -> Maybe [Char]
    txCORRECTFITID :: Maybe String
        -- ^ If present, this indicates the FITID of a previously sent
        -- transaction that is corrected by this record. This transaction
        -- replaces or deletes the transaction that it corrects, based on
        -- the value of CORRECTACTION below.

        , Transaction -> Maybe CorrectAction
    txCORRECTACTION :: Maybe CorrectAction
        -- ^ See 'CorrectAction' and 'txCORRECTFITID'

        , Transaction -> Maybe [Char]
    txSRVRTID :: Maybe String
        -- ^ Server assigned transaction ID; used for transactions
        -- initiated by client, such as payment or funds transfer

        , Transaction -> Maybe [Char]
    txCHECKNUM :: Maybe String
        -- ^ Check or other reference number

        , Transaction -> Maybe [Char]
    txREFNUM :: Maybe String
        -- ^ Reference number that uniquely identifies the
        -- transaction. Can be used in addition to or instead of a
        -- CHECKNUM.

        , Transaction -> Maybe [Char]
    txSIC :: Maybe String
        -- ^ Standard Industrial Code

        , Transaction -> Maybe [Char]
    txPAYEEID :: Maybe String
        -- ^ Payee identifier if available

        , Transaction -> Maybe (Either [Char] Payee)
    txPayeeInfo :: Maybe (Either String Payee)
        -- ^ Information on the payee. The OFX spec seems to be saying
        -- that every transaction must have either NAME, wich is \"name of
        -- payee or description of transaction\", or the Payee
        -- aggregate. The former is indicated with a Left, the latter with
        -- a Right.

        , Transaction -> Maybe (Either BankAcctTo CCAcctTo)
    txAccountTo :: Maybe (Either BankAcctTo CCAcctTo)
        -- ^ Information on a transfer. If this transaction wa sa
        -- transfer, this may contain information about the account being
        -- transferred to.

        , Transaction -> Maybe [Char]
    txMEMO :: Maybe String
        -- ^ Extra information not in NAME

        , Transaction -> Maybe (Either Currency OrigCurrency)
    txCurrency :: Maybe (Either Currency OrigCurrency)
        -- ^ Currency option. OFX spec says to choose either CURRENCY or
        -- ORIGCURRENCY.
        } deriving (Int -> Transaction -> ShowS
    [Transaction] -> ShowS
    Transaction -> [Char]
    (Int -> Transaction -> ShowS)
    -> (Transaction -> [Char])
    -> ([Transaction] -> ShowS)
    -> Show Transaction
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Transaction -> ShowS
    showsPrec :: Int -> Transaction -> ShowS
    $cshow :: Transaction -> [Char]
    show :: Transaction -> [Char]
    $cshowList :: [Transaction] -> ShowS
    showList :: [Transaction] -> ShowS
    Show, ReadPrec [Transaction]
    ReadPrec Transaction
    Int -> ReadS Transaction
    ReadS [Transaction]
    (Int -> ReadS Transaction)
    -> ReadS [Transaction]
    -> ReadPrec Transaction
    -> ReadPrec [Transaction]
    -> Read Transaction
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Transaction
    readsPrec :: Int -> ReadS Transaction
    $creadList :: ReadS [Transaction]
    readList :: ReadS [Transaction]
    $creadPrec :: ReadPrec Transaction
    readPrec :: ReadPrec Transaction
    $creadListPrec :: ReadPrec [Transaction]
    readListPrec :: ReadPrec [Transaction]
    Read, Typeable Transaction
    Typeable Transaction =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Transaction -> c Transaction)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Transaction)
    -> (Transaction -> Constr)
    -> (Transaction -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Transaction))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c Transaction))
    -> ((forall b. Data b => b -> b) -> Transaction -> Transaction)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Transaction -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Transaction -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Transaction -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> Transaction -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Transaction -> m Transaction)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Transaction -> m Transaction)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Transaction -> m Transaction)
    -> Data Transaction
    Transaction -> Constr
    Transaction -> DataType
    (forall b. Data b => b -> b) -> Transaction -> Transaction
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Transaction -> u
    forall u. (forall d. Data d => d -> u) -> Transaction -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Transaction -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Transaction -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Transaction -> m Transaction
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Transaction -> m Transaction
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Transaction
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Transaction -> c Transaction
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Transaction)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Transaction)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Transaction -> c Transaction
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Transaction -> c Transaction
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Transaction
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Transaction
    $ctoConstr :: Transaction -> Constr
    toConstr :: Transaction -> Constr
    $cdataTypeOf :: Transaction -> DataType
    dataTypeOf :: Transaction -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Transaction)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Transaction)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Transaction)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Transaction)
    $cgmapT :: (forall b. Data b => b -> b) -> Transaction -> Transaction
    gmapT :: (forall b. Data b => b -> b) -> Transaction -> Transaction
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Transaction -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Transaction -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Transaction -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Transaction -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Transaction -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Transaction -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Transaction -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Transaction -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Transaction -> m Transaction
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Transaction -> m Transaction
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Transaction -> m Transaction
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Transaction -> m Transaction
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Transaction -> m Transaction
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Transaction -> m Transaction
    Data, (forall x. Transaction -> Rep Transaction x)
    -> (forall x. Rep Transaction x -> Transaction)
    -> Generic Transaction
    forall x. Rep Transaction x -> Transaction
    forall x. Transaction -> Rep Transaction x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Transaction -> Rep Transaction x
    from :: forall x. Transaction -> Rep Transaction x
    $cto :: forall x. Rep Transaction x -> Transaction
    to :: forall x. Rep Transaction x -> Transaction
    Generic, Typeable)

    data Payee = Payee
      { Payee -> [Char]
    peNAME :: String
      , Payee -> [Char]
    peADDR1 :: String
      , Payee -> Maybe [Char]
    peADDR2 :: Maybe String
      , Payee -> Maybe [Char]
    peADDR3 :: Maybe String
      , Payee -> [Char]
    peCITY :: String
      , Payee -> [Char]
    peSTATE :: String
      , Payee -> [Char]
    pePOSTALCODE :: String
      , Payee -> Maybe [Char]
    peCOUNTRY :: Maybe String
      , Payee -> [Char]
    pePHONE :: String
      } deriving (Payee -> Payee -> Bool
    (Payee -> Payee -> Bool) -> (Payee -> Payee -> Bool) -> Eq Payee
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Payee -> Payee -> Bool
    == :: Payee -> Payee -> Bool
    $c/= :: Payee -> Payee -> Bool
    /= :: Payee -> Payee -> Bool
    Eq, Int -> Payee -> ShowS
    [Payee] -> ShowS
    Payee -> [Char]
    (Int -> Payee -> ShowS)
    -> (Payee -> [Char]) -> ([Payee] -> ShowS) -> Show Payee
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Payee -> ShowS
    showsPrec :: Int -> Payee -> ShowS
    $cshow :: Payee -> [Char]
    show :: Payee -> [Char]
    $cshowList :: [Payee] -> ShowS
    showList :: [Payee] -> ShowS
    Show, ReadPrec [Payee]
    ReadPrec Payee
    Int -> ReadS Payee
    ReadS [Payee]
    (Int -> ReadS Payee)
    -> ReadS [Payee]
    -> ReadPrec Payee
    -> ReadPrec [Payee]
    -> Read Payee
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Payee
    readsPrec :: Int -> ReadS Payee
    $creadList :: ReadS [Payee]
    readList :: ReadS [Payee]
    $creadPrec :: ReadPrec Payee
    readPrec :: ReadPrec Payee
    $creadListPrec :: ReadPrec [Payee]
    readListPrec :: ReadPrec [Payee]
    Read, Typeable Payee
    Typeable Payee =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Payee -> c Payee)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Payee)
    -> (Payee -> Constr)
    -> (Payee -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Payee))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Payee))
    -> ((forall b. Data b => b -> b) -> Payee -> Payee)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Payee -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Payee -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Payee -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> Payee -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Payee -> m Payee)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Payee -> m Payee)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Payee -> m Payee)
    -> Data Payee
    Payee -> Constr
    Payee -> DataType
    (forall b. Data b => b -> b) -> Payee -> Payee
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Payee -> u
    forall u. (forall d. Data d => d -> u) -> Payee -> [u]
    forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Payee -> r
    forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Payee -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Payee -> m Payee
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Payee -> m Payee
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Payee
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Payee -> c Payee
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Payee)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Payee)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Payee -> c Payee
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Payee -> c Payee
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Payee
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Payee
    $ctoConstr :: Payee -> Constr
    toConstr :: Payee -> Constr
    $cdataTypeOf :: Payee -> DataType
    dataTypeOf :: Payee -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Payee)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Payee)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Payee)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Payee)
    $cgmapT :: (forall b. Data b => b -> b) -> Payee -> Payee
    gmapT :: (forall b. Data b => b -> b) -> Payee -> Payee
    $cgmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Payee -> r
    gmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Payee -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Payee -> r
    gmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Payee -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Payee -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Payee -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Payee -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Payee -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Payee -> m Payee
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Payee -> m Payee
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Payee -> m Payee
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Payee -> m Payee
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Payee -> m Payee
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Payee -> m Payee
    Data, (forall x. Payee -> Rep Payee x)
    -> (forall x. Rep Payee x -> Payee) -> Generic Payee
    forall x. Rep Payee x -> Payee
    forall x. Payee -> Rep Payee x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Payee -> Rep Payee x
    from :: forall x. Payee -> Rep Payee x
    $cto :: forall x. Rep Payee x -> Payee
    to :: forall x. Rep Payee x -> Payee
    Generic, Typeable)

    -- | Can be either REPLACE or DELETE.
    data CorrectAction
      = REPLACE
      -- ^ Replaces the transaction referenced by the CORRECTFITID

      | DELETE
      -- ^ Deletes the transaction referenced by the CORRECTFITID
      deriving (CorrectAction -> CorrectAction -> Bool
    (CorrectAction -> CorrectAction -> Bool)
    -> (CorrectAction -> CorrectAction -> Bool) -> Eq CorrectAction
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: CorrectAction -> CorrectAction -> Bool
    == :: CorrectAction -> CorrectAction -> Bool
    $c/= :: CorrectAction -> CorrectAction -> Bool
    /= :: CorrectAction -> CorrectAction -> Bool
    Eq, Int -> CorrectAction -> ShowS
    [CorrectAction] -> ShowS
    CorrectAction -> [Char]
    (Int -> CorrectAction -> ShowS)
    -> (CorrectAction -> [Char])
    -> ([CorrectAction] -> ShowS)
    -> Show CorrectAction
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> CorrectAction -> ShowS
    showsPrec :: Int -> CorrectAction -> ShowS
    $cshow :: CorrectAction -> [Char]
    show :: CorrectAction -> [Char]
    $cshowList :: [CorrectAction] -> ShowS
    showList :: [CorrectAction] -> ShowS
    Show, ReadPrec [CorrectAction]
    ReadPrec CorrectAction
    Int -> ReadS CorrectAction
    ReadS [CorrectAction]
    (Int -> ReadS CorrectAction)
    -> ReadS [CorrectAction]
    -> ReadPrec CorrectAction
    -> ReadPrec [CorrectAction]
    -> Read CorrectAction
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS CorrectAction
    readsPrec :: Int -> ReadS CorrectAction
    $creadList :: ReadS [CorrectAction]
    readList :: ReadS [CorrectAction]
    $creadPrec :: ReadPrec CorrectAction
    readPrec :: ReadPrec CorrectAction
    $creadListPrec :: ReadPrec [CorrectAction]
    readListPrec :: ReadPrec [CorrectAction]
    Read, Typeable CorrectAction
    Typeable CorrectAction =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> CorrectAction -> c CorrectAction)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c CorrectAction)
    -> (CorrectAction -> Constr)
    -> (CorrectAction -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c CorrectAction))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c CorrectAction))
    -> ((forall b. Data b => b -> b) -> CorrectAction -> CorrectAction)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> CorrectAction -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> CorrectAction -> r)
    -> (forall u. (forall d. Data d => d -> u) -> CorrectAction -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> CorrectAction -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> CorrectAction -> m CorrectAction)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> CorrectAction -> m CorrectAction)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> CorrectAction -> m CorrectAction)
    -> Data CorrectAction
    CorrectAction -> Constr
    CorrectAction -> DataType
    (forall b. Data b => b -> b) -> CorrectAction -> CorrectAction
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> CorrectAction -> u
    forall u. (forall d. Data d => d -> u) -> CorrectAction -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CorrectAction -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CorrectAction -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CorrectAction -> m CorrectAction
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CorrectAction -> m CorrectAction
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CorrectAction
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CorrectAction -> c CorrectAction
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CorrectAction)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c CorrectAction)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CorrectAction -> c CorrectAction
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CorrectAction -> c CorrectAction
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CorrectAction
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CorrectAction
    $ctoConstr :: CorrectAction -> Constr
    toConstr :: CorrectAction -> Constr
    $cdataTypeOf :: CorrectAction -> DataType
    dataTypeOf :: CorrectAction -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CorrectAction)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CorrectAction)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c CorrectAction)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c CorrectAction)
    $cgmapT :: (forall b. Data b => b -> b) -> CorrectAction -> CorrectAction
    gmapT :: (forall b. Data b => b -> b) -> CorrectAction -> CorrectAction
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CorrectAction -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CorrectAction -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CorrectAction -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CorrectAction -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> CorrectAction -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> CorrectAction -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CorrectAction -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CorrectAction -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CorrectAction -> m CorrectAction
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CorrectAction -> m CorrectAction
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CorrectAction -> m CorrectAction
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CorrectAction -> m CorrectAction
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CorrectAction -> m CorrectAction
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CorrectAction -> m CorrectAction
    Data, (forall x. CorrectAction -> Rep CorrectAction x)
    -> (forall x. Rep CorrectAction x -> CorrectAction)
    -> Generic CorrectAction
    forall x. Rep CorrectAction x -> CorrectAction
    forall x. CorrectAction -> Rep CorrectAction x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. CorrectAction -> Rep CorrectAction x
    from :: forall x. CorrectAction -> Rep CorrectAction x
    $cto :: forall x. Rep CorrectAction x -> CorrectAction
    to :: forall x. Rep CorrectAction x -> CorrectAction
    Generic, Typeable)

    data BankAcctTo = BankAcctTo
      { BankAcctTo -> [Char]
    btBANKID :: String
      -- ^ Routing and transit number

      , BankAcctTo -> Maybe [Char]
    btBRANCHID :: Maybe String
      -- ^ Bank identifier for international banks

      , BankAcctTo -> [Char]
    btACCTID :: String
      -- ^ Account number

      , BankAcctTo -> AcctType
    btACCTTYPE :: AcctType
      -- ^ Type of account

      , BankAcctTo -> Maybe [Char]
    btACCTKEY :: Maybe String
      -- ^ Checksum for international banks
      } deriving (Int -> BankAcctTo -> ShowS
    [BankAcctTo] -> ShowS
    BankAcctTo -> [Char]
    (Int -> BankAcctTo -> ShowS)
    -> (BankAcctTo -> [Char])
    -> ([BankAcctTo] -> ShowS)
    -> Show BankAcctTo
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> BankAcctTo -> ShowS
    showsPrec :: Int -> BankAcctTo -> ShowS
    $cshow :: BankAcctTo -> [Char]
    show :: BankAcctTo -> [Char]
    $cshowList :: [BankAcctTo] -> ShowS
    showList :: [BankAcctTo] -> ShowS
    Show, ReadPrec [BankAcctTo]
    ReadPrec BankAcctTo
    Int -> ReadS BankAcctTo
    ReadS [BankAcctTo]
    (Int -> ReadS BankAcctTo)
    -> ReadS [BankAcctTo]
    -> ReadPrec BankAcctTo
    -> ReadPrec [BankAcctTo]
    -> Read BankAcctTo
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS BankAcctTo
    readsPrec :: Int -> ReadS BankAcctTo
    $creadList :: ReadS [BankAcctTo]
    readList :: ReadS [BankAcctTo]
    $creadPrec :: ReadPrec BankAcctTo
    readPrec :: ReadPrec BankAcctTo
    $creadListPrec :: ReadPrec [BankAcctTo]
    readListPrec :: ReadPrec [BankAcctTo]
    Read, Typeable BankAcctTo
    Typeable BankAcctTo =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> BankAcctTo -> c BankAcctTo)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c BankAcctTo)
    -> (BankAcctTo -> Constr)
    -> (BankAcctTo -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c BankAcctTo))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c BankAcctTo))
    -> ((forall b. Data b => b -> b) -> BankAcctTo -> BankAcctTo)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> BankAcctTo -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> BankAcctTo -> r)
    -> (forall u. (forall d. Data d => d -> u) -> BankAcctTo -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> BankAcctTo -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> BankAcctTo -> m BankAcctTo)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> BankAcctTo -> m BankAcctTo)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> BankAcctTo -> m BankAcctTo)
    -> Data BankAcctTo
    BankAcctTo -> Constr
    BankAcctTo -> DataType
    (forall b. Data b => b -> b) -> BankAcctTo -> BankAcctTo
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> BankAcctTo -> u
    forall u. (forall d. Data d => d -> u) -> BankAcctTo -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BankAcctTo -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BankAcctTo -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BankAcctTo -> m BankAcctTo
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BankAcctTo -> m BankAcctTo
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BankAcctTo
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BankAcctTo -> c BankAcctTo
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BankAcctTo)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BankAcctTo)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BankAcctTo -> c BankAcctTo
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BankAcctTo -> c BankAcctTo
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BankAcctTo
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BankAcctTo
    $ctoConstr :: BankAcctTo -> Constr
    toConstr :: BankAcctTo -> Constr
    $cdataTypeOf :: BankAcctTo -> DataType
    dataTypeOf :: BankAcctTo -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BankAcctTo)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BankAcctTo)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BankAcctTo)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BankAcctTo)
    $cgmapT :: (forall b. Data b => b -> b) -> BankAcctTo -> BankAcctTo
    gmapT :: (forall b. Data b => b -> b) -> BankAcctTo -> BankAcctTo
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BankAcctTo -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BankAcctTo -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BankAcctTo -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BankAcctTo -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> BankAcctTo -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> BankAcctTo -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BankAcctTo -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BankAcctTo -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BankAcctTo -> m BankAcctTo
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BankAcctTo -> m BankAcctTo
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BankAcctTo -> m BankAcctTo
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BankAcctTo -> m BankAcctTo
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BankAcctTo -> m BankAcctTo
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BankAcctTo -> m BankAcctTo
    Data, (forall x. BankAcctTo -> Rep BankAcctTo x)
    -> (forall x. Rep BankAcctTo x -> BankAcctTo) -> Generic BankAcctTo
    forall x. Rep BankAcctTo x -> BankAcctTo
    forall x. BankAcctTo -> Rep BankAcctTo x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. BankAcctTo -> Rep BankAcctTo x
    from :: forall x. BankAcctTo -> Rep BankAcctTo x
    $cto :: forall x. Rep BankAcctTo x -> BankAcctTo
    to :: forall x. Rep BankAcctTo x -> BankAcctTo
    Generic, Typeable)

    data CCAcctTo = CCAcctTo
      { CCAcctTo -> [Char]
    ctACCTID :: String
      -- ^ Account number

      , CCAcctTo -> Maybe [Char]
    ctACCTKEY :: Maybe String
      -- ^ Checksum for international banks

      } deriving (CCAcctTo -> CCAcctTo -> Bool
    (CCAcctTo -> CCAcctTo -> Bool)
    -> (CCAcctTo -> CCAcctTo -> Bool) -> Eq CCAcctTo
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: CCAcctTo -> CCAcctTo -> Bool
    == :: CCAcctTo -> CCAcctTo -> Bool
    $c/= :: CCAcctTo -> CCAcctTo -> Bool
    /= :: CCAcctTo -> CCAcctTo -> Bool
    Eq, Int -> CCAcctTo -> ShowS
    [CCAcctTo] -> ShowS
    CCAcctTo -> [Char]
    (Int -> CCAcctTo -> ShowS)
    -> (CCAcctTo -> [Char]) -> ([CCAcctTo] -> ShowS) -> Show CCAcctTo
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> CCAcctTo -> ShowS
    showsPrec :: Int -> CCAcctTo -> ShowS
    $cshow :: CCAcctTo -> [Char]
    show :: CCAcctTo -> [Char]
    $cshowList :: [CCAcctTo] -> ShowS
    showList :: [CCAcctTo] -> ShowS
    Show, ReadPrec [CCAcctTo]
    ReadPrec CCAcctTo
    Int -> ReadS CCAcctTo
    ReadS [CCAcctTo]
    (Int -> ReadS CCAcctTo)
    -> ReadS [CCAcctTo]
    -> ReadPrec CCAcctTo
    -> ReadPrec [CCAcctTo]
    -> Read CCAcctTo
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS CCAcctTo
    readsPrec :: Int -> ReadS CCAcctTo
    $creadList :: ReadS [CCAcctTo]
    readList :: ReadS [CCAcctTo]
    $creadPrec :: ReadPrec CCAcctTo
    readPrec :: ReadPrec CCAcctTo
    $creadListPrec :: ReadPrec [CCAcctTo]
    readListPrec :: ReadPrec [CCAcctTo]
    Read, Typeable CCAcctTo
    Typeable CCAcctTo =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> CCAcctTo -> c CCAcctTo)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c CCAcctTo)
    -> (CCAcctTo -> Constr)
    -> (CCAcctTo -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c CCAcctTo))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CCAcctTo))
    -> ((forall b. Data b => b -> b) -> CCAcctTo -> CCAcctTo)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> CCAcctTo -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> CCAcctTo -> r)
    -> (forall u. (forall d. Data d => d -> u) -> CCAcctTo -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> CCAcctTo -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> CCAcctTo -> m CCAcctTo)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> CCAcctTo -> m CCAcctTo)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> CCAcctTo -> m CCAcctTo)
    -> Data CCAcctTo
    CCAcctTo -> Constr
    CCAcctTo -> DataType
    (forall b. Data b => b -> b) -> CCAcctTo -> CCAcctTo
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> CCAcctTo -> u
    forall u. (forall d. Data d => d -> u) -> CCAcctTo -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CCAcctTo -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CCAcctTo -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CCAcctTo -> m CCAcctTo
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CCAcctTo -> m CCAcctTo
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CCAcctTo
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CCAcctTo -> c CCAcctTo
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CCAcctTo)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CCAcctTo)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CCAcctTo -> c CCAcctTo
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CCAcctTo -> c CCAcctTo
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CCAcctTo
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CCAcctTo
    $ctoConstr :: CCAcctTo -> Constr
    toConstr :: CCAcctTo -> Constr
    $cdataTypeOf :: CCAcctTo -> DataType
    dataTypeOf :: CCAcctTo -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CCAcctTo)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CCAcctTo)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CCAcctTo)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CCAcctTo)
    $cgmapT :: (forall b. Data b => b -> b) -> CCAcctTo -> CCAcctTo
    gmapT :: (forall b. Data b => b -> b) -> CCAcctTo -> CCAcctTo
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CCAcctTo -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CCAcctTo -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CCAcctTo -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CCAcctTo -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> CCAcctTo -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> CCAcctTo -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CCAcctTo -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CCAcctTo -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CCAcctTo -> m CCAcctTo
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CCAcctTo -> m CCAcctTo
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CCAcctTo -> m CCAcctTo
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CCAcctTo -> m CCAcctTo
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CCAcctTo -> m CCAcctTo
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CCAcctTo -> m CCAcctTo
    Data, (forall x. CCAcctTo -> Rep CCAcctTo x)
    -> (forall x. Rep CCAcctTo x -> CCAcctTo) -> Generic CCAcctTo
    forall x. Rep CCAcctTo x -> CCAcctTo
    forall x. CCAcctTo -> Rep CCAcctTo x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. CCAcctTo -> Rep CCAcctTo x
    from :: forall x. CCAcctTo -> Rep CCAcctTo x
    $cto :: forall x. Rep CCAcctTo x -> CCAcctTo
    to :: forall x. Rep CCAcctTo x -> CCAcctTo
    Generic, Typeable)

    data AcctType
      = ACHECKING
      | ASAVINGS
      | AMONEYMRKT
      | ACREDITLINE
      deriving (AcctType -> AcctType -> Bool
    (AcctType -> AcctType -> Bool)
    -> (AcctType -> AcctType -> Bool) -> Eq AcctType
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: AcctType -> AcctType -> Bool
    == :: AcctType -> AcctType -> Bool
    $c/= :: AcctType -> AcctType -> Bool
    /= :: AcctType -> AcctType -> Bool
    Eq, Int -> AcctType -> ShowS
    [AcctType] -> ShowS
    AcctType -> [Char]
    (Int -> AcctType -> ShowS)
    -> (AcctType -> [Char]) -> ([AcctType] -> ShowS) -> Show AcctType
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> AcctType -> ShowS
    showsPrec :: Int -> AcctType -> ShowS
    $cshow :: AcctType -> [Char]
    show :: AcctType -> [Char]
    $cshowList :: [AcctType] -> ShowS
    showList :: [AcctType] -> ShowS
    Show, Eq AcctType
    Eq AcctType =>
    (AcctType -> AcctType -> Ordering)
    -> (AcctType -> AcctType -> Bool)
    -> (AcctType -> AcctType -> Bool)
    -> (AcctType -> AcctType -> Bool)
    -> (AcctType -> AcctType -> Bool)
    -> (AcctType -> AcctType -> AcctType)
    -> (AcctType -> AcctType -> AcctType)
    -> Ord AcctType
    AcctType -> AcctType -> Bool
    AcctType -> AcctType -> Ordering
    AcctType -> AcctType -> AcctType
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: AcctType -> AcctType -> Ordering
    compare :: AcctType -> AcctType -> Ordering
    $c< :: AcctType -> AcctType -> Bool
    < :: AcctType -> AcctType -> Bool
    $c<= :: AcctType -> AcctType -> Bool
    <= :: AcctType -> AcctType -> Bool
    $c> :: AcctType -> AcctType -> Bool
    > :: AcctType -> AcctType -> Bool
    $c>= :: AcctType -> AcctType -> Bool
    >= :: AcctType -> AcctType -> Bool
    $cmax :: AcctType -> AcctType -> AcctType
    max :: AcctType -> AcctType -> AcctType
    $cmin :: AcctType -> AcctType -> AcctType
    min :: AcctType -> AcctType -> AcctType
    Ord, ReadPrec [AcctType]
    ReadPrec AcctType
    Int -> ReadS AcctType
    ReadS [AcctType]
    (Int -> ReadS AcctType)
    -> ReadS [AcctType]
    -> ReadPrec AcctType
    -> ReadPrec [AcctType]
    -> Read AcctType
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS AcctType
    readsPrec :: Int -> ReadS AcctType
    $creadList :: ReadS [AcctType]
    readList :: ReadS [AcctType]
    $creadPrec :: ReadPrec AcctType
    readPrec :: ReadPrec AcctType
    $creadListPrec :: ReadPrec [AcctType]
    readListPrec :: ReadPrec [AcctType]
    Read, Typeable AcctType
    Typeable AcctType =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> AcctType -> c AcctType)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c AcctType)
    -> (AcctType -> Constr)
    -> (AcctType -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c AcctType))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AcctType))
    -> ((forall b. Data b => b -> b) -> AcctType -> AcctType)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> AcctType -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> AcctType -> r)
    -> (forall u. (forall d. Data d => d -> u) -> AcctType -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> AcctType -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> AcctType -> m AcctType)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> AcctType -> m AcctType)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> AcctType -> m AcctType)
    -> Data AcctType
    AcctType -> Constr
    AcctType -> DataType
    (forall b. Data b => b -> b) -> AcctType -> AcctType
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> AcctType -> u
    forall u. (forall d. Data d => d -> u) -> AcctType -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AcctType -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AcctType -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AcctType -> m AcctType
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AcctType -> m AcctType
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AcctType
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AcctType -> c AcctType
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AcctType)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AcctType)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AcctType -> c AcctType
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AcctType -> c AcctType
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AcctType
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AcctType
    $ctoConstr :: AcctType -> Constr
    toConstr :: AcctType -> Constr
    $cdataTypeOf :: AcctType -> DataType
    dataTypeOf :: AcctType -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AcctType)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AcctType)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AcctType)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AcctType)
    $cgmapT :: (forall b. Data b => b -> b) -> AcctType -> AcctType
    gmapT :: (forall b. Data b => b -> b) -> AcctType -> AcctType
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AcctType -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AcctType -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AcctType -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AcctType -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> AcctType -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> AcctType -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AcctType -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AcctType -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AcctType -> m AcctType
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AcctType -> m AcctType
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AcctType -> m AcctType
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AcctType -> m AcctType
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AcctType -> m AcctType
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AcctType -> m AcctType
    Data, (forall x. AcctType -> Rep AcctType x)
    -> (forall x. Rep AcctType x -> AcctType) -> Generic AcctType
    forall x. Rep AcctType x -> AcctType
    forall x. AcctType -> Rep AcctType x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. AcctType -> Rep AcctType x
    from :: forall x. AcctType -> Rep AcctType x
    $cto :: forall x. Rep AcctType x -> AcctType
    to :: forall x. Rep AcctType x -> AcctType
    Generic, Typeable)

    acctType :: String -> Err AcctType
    acctType :: [Char] -> Err AcctType
    acctType [Char]
    s
      | [Char]
    s [Char] -> [Char] -> Bool
    forall a. Eq a => a -> a -> Bool
    == [Char]
    "CHECKING" = AcctType -> Err AcctType
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return AcctType
    ACHECKING
      | [Char]
    s [Char] -> [Char] -> Bool
    forall a. Eq a => a -> a -> Bool
    == [Char]
    "SAVINGS" = AcctType -> Err AcctType
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return AcctType
    ASAVINGS
      | [Char]
    s [Char] -> [Char] -> Bool
    forall a. Eq a => a -> a -> Bool
    == [Char]
    "MONEYMRKT" = AcctType -> Err AcctType
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return AcctType
    AMONEYMRKT
      | [Char]
    s [Char] -> [Char] -> Bool
    forall a. Eq a => a -> a -> Bool
    == [Char]
    "CREDITLINE" = AcctType -> Err AcctType
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return AcctType
    ACREDITLINE
      | Bool
    otherwise = [Char] -> Err AcctType
    forall a b. a -> Either a b
    Left ([Char] -> Err AcctType) -> [Char] -> Err AcctType
    forall a b. (a -> b) -> a -> b
    $ [Char]
    "unrecognized account type: " [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    s

    -- | Holds all data both for CURRENCY and for ORIGCURRENCY.
    data CurrencyData = CurrencyData

      { CurrencyData -> [Char]
    cdCURRATE :: String
      -- ^ Ratio of CURDEF currency to CURSYM currency, in decimal form

      , CurrencyData -> [Char]
    cdCURSYM :: String
      -- ^ ISO-4217 3-letter currency identifier
      } deriving (CurrencyData -> CurrencyData -> Bool
    (CurrencyData -> CurrencyData -> Bool)
    -> (CurrencyData -> CurrencyData -> Bool) -> Eq CurrencyData
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: CurrencyData -> CurrencyData -> Bool
    == :: CurrencyData -> CurrencyData -> Bool
    $c/= :: CurrencyData -> CurrencyData -> Bool
    /= :: CurrencyData -> CurrencyData -> Bool
    Eq, Int -> CurrencyData -> ShowS
    [CurrencyData] -> ShowS
    CurrencyData -> [Char]
    (Int -> CurrencyData -> ShowS)
    -> (CurrencyData -> [Char])
    -> ([CurrencyData] -> ShowS)
    -> Show CurrencyData
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> CurrencyData -> ShowS
    showsPrec :: Int -> CurrencyData -> ShowS
    $cshow :: CurrencyData -> [Char]
    show :: CurrencyData -> [Char]
    $cshowList :: [CurrencyData] -> ShowS
    showList :: [CurrencyData] -> ShowS
    Show, ReadPrec [CurrencyData]
    ReadPrec CurrencyData
    Int -> ReadS CurrencyData
    ReadS [CurrencyData]
    (Int -> ReadS CurrencyData)
    -> ReadS [CurrencyData]
    -> ReadPrec CurrencyData
    -> ReadPrec [CurrencyData]
    -> Read CurrencyData
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS CurrencyData
    readsPrec :: Int -> ReadS CurrencyData
    $creadList :: ReadS [CurrencyData]
    readList :: ReadS [CurrencyData]
    $creadPrec :: ReadPrec CurrencyData
    readPrec :: ReadPrec CurrencyData
    $creadListPrec :: ReadPrec [CurrencyData]
    readListPrec :: ReadPrec [CurrencyData]
    Read, Typeable CurrencyData
    Typeable CurrencyData =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> CurrencyData -> c CurrencyData)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c CurrencyData)
    -> (CurrencyData -> Constr)
    -> (CurrencyData -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c CurrencyData))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c CurrencyData))
    -> ((forall b. Data b => b -> b) -> CurrencyData -> CurrencyData)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> CurrencyData -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> CurrencyData -> r)
    -> (forall u. (forall d. Data d => d -> u) -> CurrencyData -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> CurrencyData -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> CurrencyData -> m CurrencyData)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> CurrencyData -> m CurrencyData)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> CurrencyData -> m CurrencyData)
    -> Data CurrencyData
    CurrencyData -> Constr
    CurrencyData -> DataType
    (forall b. Data b => b -> b) -> CurrencyData -> CurrencyData
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> CurrencyData -> u
    forall u. (forall d. Data d => d -> u) -> CurrencyData -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CurrencyData -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CurrencyData -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CurrencyData -> m CurrencyData
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CurrencyData -> m CurrencyData
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CurrencyData
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CurrencyData -> c CurrencyData
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CurrencyData)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c CurrencyData)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CurrencyData -> c CurrencyData
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CurrencyData -> c CurrencyData
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CurrencyData
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CurrencyData
    $ctoConstr :: CurrencyData -> Constr
    toConstr :: CurrencyData -> Constr
    $cdataTypeOf :: CurrencyData -> DataType
    dataTypeOf :: CurrencyData -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CurrencyData)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CurrencyData)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c CurrencyData)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c CurrencyData)
    $cgmapT :: (forall b. Data b => b -> b) -> CurrencyData -> CurrencyData
    gmapT :: (forall b. Data b => b -> b) -> CurrencyData -> CurrencyData
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CurrencyData -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CurrencyData -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CurrencyData -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CurrencyData -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> CurrencyData -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> CurrencyData -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CurrencyData -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CurrencyData -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CurrencyData -> m CurrencyData
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CurrencyData -> m CurrencyData
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CurrencyData -> m CurrencyData
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CurrencyData -> m CurrencyData
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CurrencyData -> m CurrencyData
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CurrencyData -> m CurrencyData
    Data, (forall x. CurrencyData -> Rep CurrencyData x)
    -> (forall x. Rep CurrencyData x -> CurrencyData)
    -> Generic CurrencyData
    forall x. Rep CurrencyData x -> CurrencyData
    forall x. CurrencyData -> Rep CurrencyData x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. CurrencyData -> Rep CurrencyData x
    from :: forall x. CurrencyData -> Rep CurrencyData x
    $cto :: forall x. Rep CurrencyData x -> CurrencyData
    to :: forall x. Rep CurrencyData x -> CurrencyData
    Generic, Typeable)

    data Currency = Currency CurrencyData
      deriving (Currency -> Currency -> Bool
    (Currency -> Currency -> Bool)
    -> (Currency -> Currency -> Bool) -> Eq Currency
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Currency -> Currency -> Bool
    == :: Currency -> Currency -> Bool
    $c/= :: Currency -> Currency -> Bool
    /= :: Currency -> Currency -> Bool
    Eq, Int -> Currency -> ShowS
    [Currency] -> ShowS
    Currency -> [Char]
    (Int -> Currency -> ShowS)
    -> (Currency -> [Char]) -> ([Currency] -> ShowS) -> Show Currency
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Currency -> ShowS
    showsPrec :: Int -> Currency -> ShowS
    $cshow :: Currency -> [Char]
    show :: Currency -> [Char]
    $cshowList :: [Currency] -> ShowS
    showList :: [Currency] -> ShowS
    Show, ReadPrec [Currency]
    ReadPrec Currency
    Int -> ReadS Currency
    ReadS [Currency]
    (Int -> ReadS Currency)
    -> ReadS [Currency]
    -> ReadPrec Currency
    -> ReadPrec [Currency]
    -> Read Currency
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Currency
    readsPrec :: Int -> ReadS Currency
    $creadList :: ReadS [Currency]
    readList :: ReadS [Currency]
    $creadPrec :: ReadPrec Currency
    readPrec :: ReadPrec Currency
    $creadListPrec :: ReadPrec [Currency]
    readListPrec :: ReadPrec [Currency]
    Read, Typeable Currency
    Typeable Currency =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Currency -> c Currency)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Currency)
    -> (Currency -> Constr)
    -> (Currency -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Currency))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Currency))
    -> ((forall b. Data b => b -> b) -> Currency -> Currency)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Currency -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Currency -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Currency -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> Currency -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Currency -> m Currency)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Currency -> m Currency)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Currency -> m Currency)
    -> Data Currency
    Currency -> Constr
    Currency -> DataType
    (forall b. Data b => b -> b) -> Currency -> Currency
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Currency -> u
    forall u. (forall d. Data d => d -> u) -> Currency -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Currency -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Currency -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Currency -> m Currency
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Currency -> m Currency
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Currency
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Currency -> c Currency
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Currency)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Currency)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Currency -> c Currency
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Currency -> c Currency
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Currency
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Currency
    $ctoConstr :: Currency -> Constr
    toConstr :: Currency -> Constr
    $cdataTypeOf :: Currency -> DataType
    dataTypeOf :: Currency -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Currency)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Currency)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Currency)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Currency)
    $cgmapT :: (forall b. Data b => b -> b) -> Currency -> Currency
    gmapT :: (forall b. Data b => b -> b) -> Currency -> Currency
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Currency -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Currency -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Currency -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Currency -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Currency -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Currency -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Currency -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Currency -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Currency -> m Currency
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Currency -> m Currency
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Currency -> m Currency
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Currency -> m Currency
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Currency -> m Currency
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Currency -> m Currency
    Data, (forall x. Currency -> Rep Currency x)
    -> (forall x. Rep Currency x -> Currency) -> Generic Currency
    forall x. Rep Currency x -> Currency
    forall x. Currency -> Rep Currency x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Currency -> Rep Currency x
    from :: forall x. Currency -> Rep Currency x
    $cto :: forall x. Rep Currency x -> Currency
    to :: forall x. Rep Currency x -> Currency
    Generic, Typeable)

    data OrigCurrency = OrigCurrency CurrencyData
      deriving (OrigCurrency -> OrigCurrency -> Bool
    (OrigCurrency -> OrigCurrency -> Bool)
    -> (OrigCurrency -> OrigCurrency -> Bool) -> Eq OrigCurrency
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: OrigCurrency -> OrigCurrency -> Bool
    == :: OrigCurrency -> OrigCurrency -> Bool
    $c/= :: OrigCurrency -> OrigCurrency -> Bool
    /= :: OrigCurrency -> OrigCurrency -> Bool
    Eq, Int -> OrigCurrency -> ShowS
    [OrigCurrency] -> ShowS
    OrigCurrency -> [Char]
    (Int -> OrigCurrency -> ShowS)
    -> (OrigCurrency -> [Char])
    -> ([OrigCurrency] -> ShowS)
    -> Show OrigCurrency
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> OrigCurrency -> ShowS
    showsPrec :: Int -> OrigCurrency -> ShowS
    $cshow :: OrigCurrency -> [Char]
    show :: OrigCurrency -> [Char]
    $cshowList :: [OrigCurrency] -> ShowS
    showList :: [OrigCurrency] -> ShowS
    Show, ReadPrec [OrigCurrency]
    ReadPrec OrigCurrency
    Int -> ReadS OrigCurrency
    ReadS [OrigCurrency]
    (Int -> ReadS OrigCurrency)
    -> ReadS [OrigCurrency]
    -> ReadPrec OrigCurrency
    -> ReadPrec [OrigCurrency]
    -> Read OrigCurrency
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS OrigCurrency
    readsPrec :: Int -> ReadS OrigCurrency
    $creadList :: ReadS [OrigCurrency]
    readList :: ReadS [OrigCurrency]
    $creadPrec :: ReadPrec OrigCurrency
    readPrec :: ReadPrec OrigCurrency
    $creadListPrec :: ReadPrec [OrigCurrency]
    readListPrec :: ReadPrec [OrigCurrency]
    Read, Typeable OrigCurrency
    Typeable OrigCurrency =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> OrigCurrency -> c OrigCurrency)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c OrigCurrency)
    -> (OrigCurrency -> Constr)
    -> (OrigCurrency -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c OrigCurrency))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c OrigCurrency))
    -> ((forall b. Data b => b -> b) -> OrigCurrency -> OrigCurrency)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> OrigCurrency -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> OrigCurrency -> r)
    -> (forall u. (forall d. Data d => d -> u) -> OrigCurrency -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> OrigCurrency -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> OrigCurrency -> m OrigCurrency)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> OrigCurrency -> m OrigCurrency)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> OrigCurrency -> m OrigCurrency)
    -> Data OrigCurrency
    OrigCurrency -> Constr
    OrigCurrency -> DataType
    (forall b. Data b => b -> b) -> OrigCurrency -> OrigCurrency
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> OrigCurrency -> u
    forall u. (forall d. Data d => d -> u) -> OrigCurrency -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> OrigCurrency -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> OrigCurrency -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> OrigCurrency -> m OrigCurrency
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OrigCurrency -> m OrigCurrency
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c OrigCurrency
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OrigCurrency -> c OrigCurrency
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c OrigCurrency)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c OrigCurrency)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OrigCurrency -> c OrigCurrency
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OrigCurrency -> c OrigCurrency
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c OrigCurrency
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c OrigCurrency
    $ctoConstr :: OrigCurrency -> Constr
    toConstr :: OrigCurrency -> Constr
    $cdataTypeOf :: OrigCurrency -> DataType
    dataTypeOf :: OrigCurrency -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c OrigCurrency)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c OrigCurrency)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c OrigCurrency)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c OrigCurrency)
    $cgmapT :: (forall b. Data b => b -> b) -> OrigCurrency -> OrigCurrency
    gmapT :: (forall b. Data b => b -> b) -> OrigCurrency -> OrigCurrency
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> OrigCurrency -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> OrigCurrency -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> OrigCurrency -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> OrigCurrency -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> OrigCurrency -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> OrigCurrency -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> OrigCurrency -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> OrigCurrency -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> OrigCurrency -> m OrigCurrency
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> OrigCurrency -> m OrigCurrency
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OrigCurrency -> m OrigCurrency
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OrigCurrency -> m OrigCurrency
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OrigCurrency -> m OrigCurrency
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OrigCurrency -> m OrigCurrency
    Data, (forall x. OrigCurrency -> Rep OrigCurrency x)
    -> (forall x. Rep OrigCurrency x -> OrigCurrency)
    -> Generic OrigCurrency
    forall x. Rep OrigCurrency x -> OrigCurrency
    forall x. OrigCurrency -> Rep OrigCurrency x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. OrigCurrency -> Rep OrigCurrency x
    from :: forall x. OrigCurrency -> Rep OrigCurrency x
    $cto :: forall x. Rep OrigCurrency x -> OrigCurrency
    to :: forall x. Rep OrigCurrency x -> OrigCurrency
    Generic, Typeable)

    --
    -- # Helpers to build aggregates
    --
    trnType :: TagData -> Maybe TrnType
    trnType :: [Char] -> Maybe TrnType
    trnType [Char]
    d = case [Char]
    d of
      [Char]
    "CREDIT" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TCREDIT
      [Char]
    "DEBIT" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TDEBIT
      [Char]
    "INT" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TINT
      [Char]
    "DIV" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TDIV
      [Char]
    "FEE" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TFEE
      [Char]
    "SRVCHG" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TSRVCHG
      [Char]
    "DEP" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TDEP
      [Char]
    "ATM" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TATM
      [Char]
    "POS" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TPOS
      [Char]
    "XFER" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TXFER
      [Char]
    "CHECK" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TCHECK
      [Char]
    "PAYMENT" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TPAYMENT
      [Char]
    "CASH" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TCASH
      [Char]
    "DIRECTDEP" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TDIRECTDEP
      [Char]
    "DIRECTDEBIT" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TDIRECTDEBIT
      [Char]
    "REPEATPMT" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TREPEATPMT
      [Char]
    "OTHER" -> TrnType -> Maybe TrnType
    forall a. a -> Maybe a
    Just TrnType
    TOTHER
      [Char]
    _ -> Maybe TrnType
    forall a. Maybe a
    Nothing

    -- | Gets a single Transaction from a tag. The tag should be the one
    -- named STMTTRN. Fails with an error message if any required field
    -- was not present.
    transaction :: Tag -> Err Transaction
    transaction :: Tag -> Err Transaction
    transaction Tag
    t = do
      let fromMaybe :: a -> Maybe b -> Either a b
    fromMaybe a
    e = Either a b -> (b -> Either a b) -> Maybe b -> Either a b
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (a -> Either a b
    forall a b. a -> Either a b
    Left a
    e) b -> Either a b
    forall a b. b -> Either a b
    Right
      [Char]
    trntyStr <- [Char] -> Tag -> Err [Char]
    required [Char]
    "TRNTYPE" Tag
    t
      TrnType
    trnTy <- [Char] -> Maybe TrnType -> Either [Char] TrnType
    forall {a} {b}. a -> Maybe b -> Either a b
    fromMaybe ([Char]
    "could not parse transaction type: " [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    trntyStr)
               (Maybe TrnType -> Either [Char] TrnType)
    -> Maybe TrnType -> Either [Char] TrnType
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Maybe TrnType
    trnType [Char]
    trntyStr

      [Char]
    dtpStr <- [Char] -> Tag -> Err [Char]
    required [Char]
    "DTPOSTED" Tag
    t
      ZonedTime
    dtp <- [Char] -> Err ZonedTime
    parseDate [Char]
    dtpStr

      let mayDtuStr :: Maybe [Char]
    mayDtuStr = [Char] -> Tag -> Maybe [Char]
    findData [Char]
    "DTUSER" Tag
    t
      Maybe ZonedTime
    dtu <- Either [Char] (Maybe ZonedTime)
    -> ([Char] -> Either [Char] (Maybe ZonedTime))
    -> Maybe [Char]
    -> Either [Char] (Maybe ZonedTime)
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (Maybe ZonedTime -> Either [Char] (Maybe ZonedTime)
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe ZonedTime
    forall a. Maybe a
    Nothing) ((ZonedTime -> Maybe ZonedTime)
    -> Err ZonedTime -> Either [Char] (Maybe ZonedTime)
    forall a b. (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ZonedTime -> Maybe ZonedTime
    forall a. a -> Maybe a
    Just (Err ZonedTime -> Either [Char] (Maybe ZonedTime))
    -> ([Char] -> Err ZonedTime)
    -> [Char]
    -> Either [Char] (Maybe ZonedTime)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Err ZonedTime
    parseDate) Maybe [Char]
    mayDtuStr

      let mayDtAvail :: Maybe [Char]
    mayDtAvail = [Char] -> Tag -> Maybe [Char]
    findData [Char]
    "DTAVAIL" Tag
    t

      Maybe ZonedTime
    dta <- Either [Char] (Maybe ZonedTime)
    -> ([Char] -> Either [Char] (Maybe ZonedTime))
    -> Maybe [Char]
    -> Either [Char] (Maybe ZonedTime)
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (Maybe ZonedTime -> Either [Char] (Maybe ZonedTime)
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe ZonedTime
    forall a. Maybe a
    Nothing) ((ZonedTime -> Maybe ZonedTime)
    -> Err ZonedTime -> Either [Char] (Maybe ZonedTime)
    forall a b. (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ZonedTime -> Maybe ZonedTime
    forall a. a -> Maybe a
    Just (Err ZonedTime -> Either [Char] (Maybe ZonedTime))
    -> ([Char] -> Err ZonedTime)
    -> [Char]
    -> Either [Char] (Maybe ZonedTime)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Err ZonedTime
    parseDate) Maybe [Char]
    mayDtAvail
      [Char]
    amt <- [Char] -> Tag -> Err [Char]
    required [Char]
    "TRNAMT" Tag
    t
      [Char]
    fitid <- [Char] -> Tag -> Err [Char]
    required [Char]
    "FITID" Tag
    t
      let correctFitId :: Maybe [Char]
    correctFitId = [Char] -> Tag -> Maybe [Char]
    findData [Char]
    "CORRECTFITID" Tag
    t
      Maybe CorrectAction
    correctAct <-
        case [Char] -> Tag -> Maybe [Char]
    findData [Char]
    "CORRECTACTION" Tag
    t of
          Maybe [Char]
    Nothing -> Maybe CorrectAction -> Either [Char] (Maybe CorrectAction)
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe CorrectAction
    forall a. Maybe a
    Nothing
          Just [Char]
    d ->
            Either [Char] (Maybe CorrectAction)
    -> (Maybe (Maybe CorrectAction)
        -> Either [Char] (Maybe CorrectAction))
    -> Maybe (Maybe (Maybe CorrectAction))
    -> Either [Char] (Maybe CorrectAction)
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (Maybe CorrectAction -> Either [Char] (Maybe CorrectAction)
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe CorrectAction
    forall a. Maybe a
    Nothing)
              ([Char]
    -> Maybe (Maybe CorrectAction)
    -> Either [Char] (Maybe CorrectAction)
    forall {a} {b}. a -> Maybe b -> Either a b
    fromMaybe ([Char]
    "could not parse correct action: " [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    d))
            (Maybe (Maybe (Maybe CorrectAction))
     -> Either [Char] (Maybe CorrectAction))
    -> ([Char] -> Maybe (Maybe (Maybe CorrectAction)))
    -> [Char]
    -> Either [Char] (Maybe CorrectAction)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Maybe (Maybe (Maybe CorrectAction))
    forall a. Read a => [Char] -> Maybe a
    safeRead
            ([Char] -> Either [Char] (Maybe CorrectAction))
    -> [Char] -> Either [Char] (Maybe CorrectAction)
    forall a b. (a -> b) -> a -> b
    $ [Char]
    d
      let srvrtid :: Maybe [Char]
    srvrtid = [Char] -> Tag -> Maybe [Char]
    findData [Char]
    "SRVRTID" Tag
    t
          checknum :: Maybe [Char]
    checknum = [Char] -> Tag -> Maybe [Char]
    findData [Char]
    "CHECKNUM" Tag
    t
          refnum :: Maybe [Char]
    refnum = [Char] -> Tag -> Maybe [Char]
    findData [Char]
    "REFNUM" Tag
    t
          sic :: Maybe [Char]
    sic = [Char] -> Tag -> Maybe [Char]
    findData [Char]
    "SIC" Tag
    t
          payeeId :: Maybe [Char]
    payeeId = [Char] -> Tag -> Maybe [Char]
    findData [Char]
    "PAYEEID" Tag
    t

      let mayPyeInfo :: Maybe (Either [Char] (Either [Char] Payee))
    mayPyeInfo = ([Char] -> Either [Char] (Either [Char] Payee))
    -> Maybe [Char] -> Maybe (Either [Char] (Either [Char] Payee))
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (Either [Char] Payee -> Either [Char] (Either [Char] Payee)
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Either [Char] Payee -> Either [Char] (Either [Char] Payee))
    -> ([Char] -> Either [Char] Payee)
    -> [Char]
    -> Either [Char] (Either [Char] Payee)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Either [Char] Payee
    forall a b. a -> Either a b
    Left) ([Char] -> Tag -> Maybe [Char]
    findData [Char]
    "NAME" Tag
    t)
                       Maybe (Either [Char] (Either [Char] Payee))
    -> Maybe (Either [Char] (Either [Char] Payee))
    -> Maybe (Either [Char] (Either [Char] Payee))
    forall a. Maybe a -> Maybe a -> Maybe a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> (Either [Char] Payee -> Either [Char] (Either [Char] Payee))
    -> Maybe (Either [Char] Payee)
    -> Maybe (Either [Char] (Either [Char] Payee))
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((Payee -> Either [Char] Payee)
    -> Either [Char] Payee -> Either [Char] (Either [Char] Payee)
    forall a b. (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Payee -> Either [Char] Payee
    forall a b. b -> Either a b
    Right) (Tag -> Maybe (Either [Char] Payee)
    payee Tag
    t)
      Maybe (Either [Char] Payee)
    pyeInfo <- Either [Char] (Maybe (Either [Char] Payee))
    -> (Either [Char] (Either [Char] Payee)
        -> Either [Char] (Maybe (Either [Char] Payee)))
    -> Maybe (Either [Char] (Either [Char] Payee))
    -> Either [Char] (Maybe (Either [Char] Payee))
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (Maybe (Either [Char] Payee)
    -> Either [Char] (Maybe (Either [Char] Payee))
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe (Either [Char] Payee)
    forall a. Maybe a
    Nothing) ((Either [Char] Payee -> Maybe (Either [Char] Payee))
    -> Either [Char] (Either [Char] Payee)
    -> Either [Char] (Maybe (Either [Char] Payee))
    forall a b. (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Either [Char] Payee -> Maybe (Either [Char] Payee)
    forall a. a -> Maybe a
    Just) Maybe (Either [Char] (Either [Char] Payee))
    mayPyeInfo

      let mayAcctTo :: Maybe (Either [Char] (Either BankAcctTo CCAcctTo))
    mayAcctTo = ((Err BankAcctTo -> Either [Char] (Either BankAcctTo CCAcctTo))
    -> Maybe (Err BankAcctTo)
    -> Maybe (Either [Char] (Either BankAcctTo CCAcctTo))
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((BankAcctTo -> Either BankAcctTo CCAcctTo)
    -> Err BankAcctTo -> Either [Char] (Either BankAcctTo CCAcctTo)
    forall a b. (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap BankAcctTo -> Either BankAcctTo CCAcctTo
    forall a b. a -> Either a b
    Left) (Maybe (Err BankAcctTo)
     -> Maybe (Either [Char] (Either BankAcctTo CCAcctTo)))
    -> Maybe (Err BankAcctTo)
    -> Maybe (Either [Char] (Either BankAcctTo CCAcctTo))
    forall a b. (a -> b) -> a -> b
    $ Tag -> Maybe (Err BankAcctTo)
    bankAcctTo Tag
    t)
                   Maybe (Either [Char] (Either BankAcctTo CCAcctTo))
    -> Maybe (Either [Char] (Either BankAcctTo CCAcctTo))
    -> Maybe (Either [Char] (Either BankAcctTo CCAcctTo))
    forall a. Maybe a -> Maybe a -> Maybe a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> ((Err CCAcctTo -> Either [Char] (Either BankAcctTo CCAcctTo))
    -> Maybe (Err CCAcctTo)
    -> Maybe (Either [Char] (Either BankAcctTo CCAcctTo))
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((CCAcctTo -> Either BankAcctTo CCAcctTo)
    -> Err CCAcctTo -> Either [Char] (Either BankAcctTo CCAcctTo)
    forall a b. (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap CCAcctTo -> Either BankAcctTo CCAcctTo
    forall a b. b -> Either a b
    Right) (Maybe (Err CCAcctTo)
     -> Maybe (Either [Char] (Either BankAcctTo CCAcctTo)))
    -> Maybe (Err CCAcctTo)
    -> Maybe (Either [Char] (Either BankAcctTo CCAcctTo))
    forall a b. (a -> b) -> a -> b
    $ Tag -> Maybe (Err CCAcctTo)
    ccAcctTo Tag
    t)
          mayCcy :: Maybe (Either [Char] (Either Currency OrigCurrency))
    mayCcy = ((Err Currency -> Either [Char] (Either Currency OrigCurrency))
    -> Maybe (Err Currency)
    -> Maybe (Either [Char] (Either Currency OrigCurrency))
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((Currency -> Either Currency OrigCurrency)
    -> Err Currency -> Either [Char] (Either Currency OrigCurrency)
    forall a b. (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Currency -> Either Currency OrigCurrency
    forall a b. a -> Either a b
    Left) (Maybe (Err Currency)
     -> Maybe (Either [Char] (Either Currency OrigCurrency)))
    -> Maybe (Err Currency)
    -> Maybe (Either [Char] (Either Currency OrigCurrency))
    forall a b. (a -> b) -> a -> b
    $ Tag -> Maybe (Err Currency)
    currency Tag
    t)
                Maybe (Either [Char] (Either Currency OrigCurrency))
    -> Maybe (Either [Char] (Either Currency OrigCurrency))
    -> Maybe (Either [Char] (Either Currency OrigCurrency))
    forall a. Maybe a -> Maybe a -> Maybe a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> ((Err OrigCurrency -> Either [Char] (Either Currency OrigCurrency))
    -> Maybe (Err OrigCurrency)
    -> Maybe (Either [Char] (Either Currency OrigCurrency))
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((OrigCurrency -> Either Currency OrigCurrency)
    -> Err OrigCurrency -> Either [Char] (Either Currency OrigCurrency)
    forall a b. (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap OrigCurrency -> Either Currency OrigCurrency
    forall a b. b -> Either a b
    Right) (Maybe (Err OrigCurrency)
     -> Maybe (Either [Char] (Either Currency OrigCurrency)))
    -> Maybe (Err OrigCurrency)
    -> Maybe (Either [Char] (Either Currency OrigCurrency))
    forall a b. (a -> b) -> a -> b
    $ Tag -> Maybe (Err OrigCurrency)
    origCurrency Tag
    t)
      Maybe (Either BankAcctTo CCAcctTo)
    acctTo <- Either [Char] (Maybe (Either BankAcctTo CCAcctTo))
    -> (Either [Char] (Either BankAcctTo CCAcctTo)
        -> Either [Char] (Maybe (Either BankAcctTo CCAcctTo)))
    -> Maybe (Either [Char] (Either BankAcctTo CCAcctTo))
    -> Either [Char] (Maybe (Either BankAcctTo CCAcctTo))
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (Maybe (Either BankAcctTo CCAcctTo)
    -> Either [Char] (Maybe (Either BankAcctTo CCAcctTo))
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe (Either BankAcctTo CCAcctTo)
    forall a. Maybe a
    Nothing) ((Either BankAcctTo CCAcctTo -> Maybe (Either BankAcctTo CCAcctTo))
    -> Either [Char] (Either BankAcctTo CCAcctTo)
    -> Either [Char] (Maybe (Either BankAcctTo CCAcctTo))
    forall a b. (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Either BankAcctTo CCAcctTo -> Maybe (Either BankAcctTo CCAcctTo)
    forall a. a -> Maybe a
    Just) Maybe (Either [Char] (Either BankAcctTo CCAcctTo))
    mayAcctTo
      Maybe (Either Currency OrigCurrency)
    ccy <- Either [Char] (Maybe (Either Currency OrigCurrency))
    -> (Either [Char] (Either Currency OrigCurrency)
        -> Either [Char] (Maybe (Either Currency OrigCurrency)))
    -> Maybe (Either [Char] (Either Currency OrigCurrency))
    -> Either [Char] (Maybe (Either Currency OrigCurrency))
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (Maybe (Either Currency OrigCurrency)
    -> Either [Char] (Maybe (Either Currency OrigCurrency))
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe (Either Currency OrigCurrency)
    forall a. Maybe a
    Nothing) ((Either Currency OrigCurrency
     -> Maybe (Either Currency OrigCurrency))
    -> Either [Char] (Either Currency OrigCurrency)
    -> Either [Char] (Maybe (Either Currency OrigCurrency))
    forall a b. (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Either Currency OrigCurrency
    -> Maybe (Either Currency OrigCurrency)
    forall a. a -> Maybe a
    Just) Maybe (Either [Char] (Either Currency OrigCurrency))
    mayCcy
      let memo :: Maybe [Char]
    memo = [Char] -> Tag -> Maybe [Char]
    findData [Char]
    "MEMO" Tag
    t

      Transaction -> Err Transaction
    forall a. a -> Either [Char] a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Transaction
        { txTRNTYPE :: TrnType
    txTRNTYPE = TrnType
    trnTy
        , txDTPOSTED :: ZonedTime
    txDTPOSTED = ZonedTime
    dtp
        , txDTUSER :: Maybe ZonedTime
    txDTUSER = Maybe ZonedTime
    dtu
        , txDTAVAIL :: Maybe ZonedTime
    txDTAVAIL = Maybe ZonedTime
    dta
        , txTRNAMT :: [Char]
    txTRNAMT = [Char]
    amt
        , txFITID :: [Char]
    txFITID = [Char]
    fitid
        , txCORRECTFITID :: Maybe [Char]
    txCORRECTFITID = Maybe [Char]
    correctFitId
        , txCORRECTACTION :: Maybe CorrectAction
    txCORRECTACTION = Maybe CorrectAction
    correctAct
        , txSRVRTID :: Maybe [Char]
    txSRVRTID = Maybe [Char]
    srvrtid
        , txCHECKNUM :: Maybe [Char]
    txCHECKNUM = Maybe [Char]
    checknum
        , txREFNUM :: Maybe [Char]
    txREFNUM = Maybe [Char]
    refnum
        , txSIC :: Maybe [Char]
    txSIC = Maybe [Char]
    sic
        , txPAYEEID :: Maybe [Char]
    txPAYEEID = Maybe [Char]
    payeeId
        , txPayeeInfo :: Maybe (Either [Char] Payee)
    txPayeeInfo = Maybe (Either [Char] Payee)
    pyeInfo
        , txAccountTo :: Maybe (Either BankAcctTo CCAcctTo)
    txAccountTo = Maybe (Either BankAcctTo CCAcctTo)
    acctTo
        , txMEMO :: Maybe [Char]
    txMEMO = Maybe [Char]
    memo
        , txCurrency :: Maybe (Either Currency OrigCurrency)
    txCurrency = Maybe (Either Currency OrigCurrency)
    ccy
        }

    -- | Parses a Payee record from its parent tag.
    payee
      :: Tag
      -- ^ The tag which contains the PAYEE tag, if there is one. This
      -- would typically be a STMTTRN tag.

      -> Maybe (Err Payee)
      -- ^ Nothing if there is no PAYEE tag. Just if a PAYEE tag is found,
      -- with a Left if the tag is lacking a required element, or a
      -- Right if the tag is successfully parsed.
      --
      -- If there is more than one PAYEE tag, only the first one is
      -- considered.
    payee :: Tag -> Maybe (Either [Char] Payee)
    payee = (Tag -> Either [Char] Payee)
    -> Maybe Tag -> Maybe (Either [Char] Payee)
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Tag -> Either [Char] Payee
    getPayee (Maybe Tag -> Maybe (Either [Char] Payee))
    -> (Tag -> Maybe Tag) -> Tag -> Maybe (Either [Char] Payee)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Tag] -> Maybe Tag
    forall a. [a] -> Maybe a
    listToMaybe ([Tag] -> Maybe Tag) -> (Tag -> [Tag]) -> Tag -> Maybe Tag
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Tag -> [Tag]
    find [Char]
    "PAYEE"
      where
        getPayee :: Tag -> Either [Char] Payee
    getPayee Tag
    t = [Char]
    -> [Char]
    -> Maybe [Char]
    -> Maybe [Char]
    -> [Char]
    -> [Char]
    -> [Char]
    -> Maybe [Char]
    -> [Char]
    -> Payee
    Payee
          ([Char]
     -> [Char]
     -> Maybe [Char]
     -> Maybe [Char]
     -> [Char]
     -> [Char]
     -> [Char]
     -> Maybe [Char]
     -> [Char]
     -> Payee)
    -> Err [Char]
    -> Either
         [Char]
         ([Char]
          -> Maybe [Char]
          -> Maybe [Char]
          -> [Char]
          -> [Char]
          -> [Char]
          -> Maybe [Char]
          -> [Char]
          -> Payee)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Char] -> Tag -> Err [Char]
    required [Char]
    "NAME" Tag
    t
          Either
      [Char]
      ([Char]
       -> Maybe [Char]
       -> Maybe [Char]
       -> [Char]
       -> [Char]
       -> [Char]
       -> Maybe [Char]
       -> [Char]
       -> Payee)
    -> Err [Char]
    -> Either
         [Char]
         (Maybe [Char]
          -> Maybe [Char]
          -> [Char]
          -> [Char]
          -> [Char]
          -> Maybe [Char]
          -> [Char]
          -> Payee)
    forall a b.
    Either [Char] (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Char] -> Tag -> Err [Char]
    required [Char]
    "ADDR1" Tag
    t
          Either
      [Char]
      (Maybe [Char]
       -> Maybe [Char]
       -> [Char]
       -> [Char]
       -> [Char]
       -> Maybe [Char]
       -> [Char]
       -> Payee)
    -> Either [Char] (Maybe [Char])
    -> Either
         [Char]
         (Maybe [Char]
          -> [Char] -> [Char] -> [Char] -> Maybe [Char] -> [Char] -> Payee)
    forall a b.
    Either [Char] (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Maybe [Char] -> Either [Char] (Maybe [Char])
    forall a. a -> Either [Char] a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ([Char] -> Tag -> Maybe [Char]
    findData [Char]
    "ADDR2" Tag
    t)
          Either
      [Char]
      (Maybe [Char]
       -> [Char] -> [Char] -> [Char] -> Maybe [Char] -> [Char] -> Payee)
    -> Either [Char] (Maybe [Char])
    -> Either
         [Char]
         ([Char] -> [Char] -> [Char] -> Maybe [Char] -> [Char] -> Payee)
    forall a b.
    Either [Char] (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Maybe [Char] -> Either [Char] (Maybe [Char])
    forall a. a -> Either [Char] a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ([Char] -> Tag -> Maybe [Char]
    findData [Char]
    "ADDR3" Tag
    t)
          Either
      [Char]
      ([Char] -> [Char] -> [Char] -> Maybe [Char] -> [Char] -> Payee)
    -> Err [Char]
    -> Either
         [Char] ([Char] -> [Char] -> Maybe [Char] -> [Char] -> Payee)
    forall a b.
    Either [Char] (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Char] -> Tag -> Err [Char]
    required [Char]
    "CITY" Tag
    t
          Either [Char] ([Char] -> [Char] -> Maybe [Char] -> [Char] -> Payee)
    -> Err [Char]
    -> Either [Char] ([Char] -> Maybe [Char] -> [Char] -> Payee)
    forall a b.
    Either [Char] (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Char] -> Tag -> Err [Char]
    required [Char]
    "STATE" Tag
    t
          Either [Char] ([Char] -> Maybe [Char] -> [Char] -> Payee)
    -> Err [Char] -> Either [Char] (Maybe [Char] -> [Char] -> Payee)
    forall a b.
    Either [Char] (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Char] -> Tag -> Err [Char]
    required [Char]
    "POSTALCODE" Tag
    t
          Either [Char] (Maybe [Char] -> [Char] -> Payee)
    -> Either [Char] (Maybe [Char]) -> Either [Char] ([Char] -> Payee)
    forall a b.
    Either [Char] (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Maybe [Char] -> Either [Char] (Maybe [Char])
    forall a. a -> Either [Char] a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ([Char] -> Tag -> Maybe [Char]
    findData [Char]
    "COUNTRY" Tag
    t)
          Either [Char] ([Char] -> Payee)
    -> Err [Char] -> Either [Char] Payee
    forall a b.
    Either [Char] (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Char] -> Tag -> Err [Char]
    required [Char]
    "PHONE" Tag
    t

    currency :: Tag -> Maybe (Err Currency)
    currency :: Tag -> Maybe (Err Currency)
    currency
      = (Either [Char] CurrencyData -> Err Currency)
    -> Maybe (Either [Char] CurrencyData) -> Maybe (Err Currency)
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((CurrencyData -> Currency)
    -> Either [Char] CurrencyData -> Err Currency
    forall a b. (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap CurrencyData -> Currency
    Currency)
      (Maybe (Either [Char] CurrencyData) -> Maybe (Err Currency))
    -> (Tag -> Maybe (Either [Char] CurrencyData))
    -> Tag
    -> Maybe (Err Currency)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Tag -> Either [Char] CurrencyData)
    -> Maybe Tag -> Maybe (Either [Char] CurrencyData)
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Tag -> Either [Char] CurrencyData
    currencyData
      (Maybe Tag -> Maybe (Either [Char] CurrencyData))
    -> (Tag -> Maybe Tag) -> Tag -> Maybe (Either [Char] CurrencyData)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Tag] -> Maybe Tag
    forall a. [a] -> Maybe a
    listToMaybe
      ([Tag] -> Maybe Tag) -> (Tag -> [Tag]) -> Tag -> Maybe Tag
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Tag -> [Tag]
    find [Char]
    "CURRENCY"

    origCurrency :: Tag -> Maybe (Err OrigCurrency)
    origCurrency :: Tag -> Maybe (Err OrigCurrency)
    origCurrency
      = (Either [Char] CurrencyData -> Err OrigCurrency)
    -> Maybe (Either [Char] CurrencyData) -> Maybe (Err OrigCurrency)
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((CurrencyData -> OrigCurrency)
    -> Either [Char] CurrencyData -> Err OrigCurrency
    forall a b. (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap CurrencyData -> OrigCurrency
    OrigCurrency)
      (Maybe (Either [Char] CurrencyData) -> Maybe (Err OrigCurrency))
    -> (Tag -> Maybe (Either [Char] CurrencyData))
    -> Tag
    -> Maybe (Err OrigCurrency)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Tag -> Either [Char] CurrencyData)
    -> Maybe Tag -> Maybe (Either [Char] CurrencyData)
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Tag -> Either [Char] CurrencyData
    currencyData
      (Maybe Tag -> Maybe (Either [Char] CurrencyData))
    -> (Tag -> Maybe Tag) -> Tag -> Maybe (Either [Char] CurrencyData)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Tag] -> Maybe Tag
    forall a. [a] -> Maybe a
    listToMaybe
      ([Tag] -> Maybe Tag) -> (Tag -> [Tag]) -> Tag -> Maybe Tag
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Tag -> [Tag]
    find [Char]
    "ORIGCURRENCY"

    -- | Parses currency data.
    currencyData
      :: Tag
      -- ^ The tag that contains the data, e.g. CURRENCY or ORIGCURRENCY.

      -> Err CurrencyData
    currencyData :: Tag -> Either [Char] CurrencyData
    currencyData Tag
    t = [Char] -> [Char] -> CurrencyData
    CurrencyData
      ([Char] -> [Char] -> CurrencyData)
    -> Err [Char] -> Either [Char] ([Char] -> CurrencyData)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Char] -> Tag -> Err [Char]
    required [Char]
    "CURRATE" Tag
    t
      Either [Char] ([Char] -> CurrencyData)
    -> Err [Char] -> Either [Char] CurrencyData
    forall a b.
    Either [Char] (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Char] -> Tag -> Err [Char]
    required [Char]
    "CURSYM" Tag
    t

    bankAcctTo :: Tag -> Maybe (Err BankAcctTo)
    bankAcctTo :: Tag -> Maybe (Err BankAcctTo)
    bankAcctTo = (Tag -> Err BankAcctTo) -> Maybe Tag -> Maybe (Err BankAcctTo)
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Tag -> Err BankAcctTo
    getTo (Maybe Tag -> Maybe (Err BankAcctTo))
    -> (Tag -> Maybe Tag) -> Tag -> Maybe (Err BankAcctTo)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Tag] -> Maybe Tag
    forall a. [a] -> Maybe a
    listToMaybe ([Tag] -> Maybe Tag) -> (Tag -> [Tag]) -> Tag -> Maybe Tag
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Tag -> [Tag]
    find [Char]
    "BANKACCTTO"
      where
        getTo :: Tag -> Err BankAcctTo
    getTo Tag
    t = [Char]
    -> Maybe [Char] -> [Char] -> AcctType -> Maybe [Char] -> BankAcctTo
    BankAcctTo
          ([Char]
     -> Maybe [Char]
     -> [Char]
     -> AcctType
     -> Maybe [Char]
     -> BankAcctTo)
    -> Err [Char]
    -> Either
         [Char]
         (Maybe [Char] -> [Char] -> AcctType -> Maybe [Char] -> BankAcctTo)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Char] -> Tag -> Err [Char]
    required [Char]
    "BANKID" Tag
    t
          Either
      [Char]
      (Maybe [Char] -> [Char] -> AcctType -> Maybe [Char] -> BankAcctTo)
    -> Either [Char] (Maybe [Char])
    -> Either [Char] ([Char] -> AcctType -> Maybe [Char] -> BankAcctTo)
    forall a b.
    Either [Char] (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Maybe [Char] -> Either [Char] (Maybe [Char])
    forall a. a -> Either [Char] a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ([Char] -> Tag -> Maybe [Char]
    findData [Char]
    "BRANCHID" Tag
    t)
          Either [Char] ([Char] -> AcctType -> Maybe [Char] -> BankAcctTo)
    -> Err [Char]
    -> Either [Char] (AcctType -> Maybe [Char] -> BankAcctTo)
    forall a b.
    Either [Char] (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Char] -> Tag -> Err [Char]
    required [Char]
    "ACCTID" Tag
    t
          Either [Char] (AcctType -> Maybe [Char] -> BankAcctTo)
    -> Err AcctType -> Either [Char] (Maybe [Char] -> BankAcctTo)
    forall a b.
    Either [Char] (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ([Char] -> Tag -> Err [Char]
    required [Char]
    "ACCTTYPE" Tag
    t Err [Char] -> ([Char] -> Err AcctType) -> Err AcctType
    forall a b.
    Either [Char] a -> (a -> Either [Char] b) -> Either [Char] b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= [Char] -> Err AcctType
    acctType)
          Either [Char] (Maybe [Char] -> BankAcctTo)
    -> Either [Char] (Maybe [Char]) -> Err BankAcctTo
    forall a b.
    Either [Char] (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Maybe [Char] -> Either [Char] (Maybe [Char])
    forall a. a -> Either [Char] a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ([Char] -> Tag -> Maybe [Char]
    findData [Char]
    "ACCTKEY" Tag
    t)

    ccAcctTo :: Tag -> Maybe (Err CCAcctTo)
    ccAcctTo :: Tag -> Maybe (Err CCAcctTo)
    ccAcctTo = (Tag -> Err CCAcctTo) -> Maybe Tag -> Maybe (Err CCAcctTo)
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Tag -> Err CCAcctTo
    getTo (Maybe Tag -> Maybe (Err CCAcctTo))
    -> (Tag -> Maybe Tag) -> Tag -> Maybe (Err CCAcctTo)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Tag] -> Maybe Tag
    forall a. [a] -> Maybe a
    listToMaybe ([Tag] -> Maybe Tag) -> (Tag -> [Tag]) -> Tag -> Maybe Tag
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Tag -> [Tag]
    find [Char]
    "CCACCTTO"
      where
        getTo :: Tag -> Err CCAcctTo
    getTo Tag
    t = [Char] -> Maybe [Char] -> CCAcctTo
    CCAcctTo
          ([Char] -> Maybe [Char] -> CCAcctTo)
    -> Err [Char] -> Either [Char] (Maybe [Char] -> CCAcctTo)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Char] -> Tag -> Err [Char]
    required [Char]
    "ACCTID" Tag
    t
          Either [Char] (Maybe [Char] -> CCAcctTo)
    -> Either [Char] (Maybe [Char]) -> Err CCAcctTo
    forall a b.
    Either [Char] (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Maybe [Char] -> Either [Char] (Maybe [Char])
    forall a. a -> Either [Char] a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ([Char] -> Tag -> Maybe [Char]
    findData [Char]
    "ACCTKEY" Tag
    t)

    safeRead :: Read a => String -> Maybe a
    safeRead :: forall a. Read a => [Char] -> Maybe a
    safeRead [Char]
    s = case ReadS a
    forall a. Read a => ReadS a
    reads [Char]
    s of
      (a
    x, [Char]
    ""):[] -> a -> Maybe a
    forall a. a -> Maybe a
    Just a
    x
      [(a, [Char])]
    _ -> Maybe a
    forall a. Maybe a
    Nothing

    -- | Pulls all Transactions from a file. Might fail if the OFX file
    -- does not conform to the specification (or if there are bugs in this
    -- library.) In case of the former, you can manually parse the
    -- transaction information yourself using functions like
    -- 'pathData'. In case of the latter, please send bugreports :-)
    transactions :: OFXFile -> Err [Transaction]
    transactions :: OFXFile -> Err [Transaction]
    transactions = (Tag -> Err Transaction) -> [Tag] -> Err [Transaction]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
    mapM Tag -> Err Transaction
    transaction ([Tag] -> Err [Transaction])
    -> (OFXFile -> [Tag]) -> OFXFile -> Err [Transaction]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Tag -> [Tag]
    find [Char]
    "STMTTRN" (Tag -> [Tag]) -> (OFXFile -> Tag) -> OFXFile -> [Tag]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . OFXFile -> Tag
    fTag

    --
    -- # Pretty printers
    --
    pPayee :: Payee -> Doc
    pPayee :: Payee -> Doc
    pPayee Payee
    p = Doc -> Int -> Doc -> Doc
    hang Doc
    "Payee:" Int
    2 Doc
    ls
      where
        ls :: Doc
    ls = [Doc] -> Doc
    sep [ [Char] -> Doc -> Doc
    label [Char]
    "Name" ([Char] -> Doc
    text ([Char] -> Doc) -> (Payee -> [Char]) -> Payee -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Payee -> [Char]
    peNAME (Payee -> Doc) -> Payee -> Doc
    forall a b. (a -> b) -> a -> b
    $ Payee
    p)
                 , [Char] -> Doc -> Doc
    label [Char]
    "Addr1" ([Char] -> Doc
    text ([Char] -> Doc) -> (Payee -> [Char]) -> Payee -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Payee -> [Char]
    peADDR1 (Payee -> Doc) -> Payee -> Doc
    forall a b. (a -> b) -> a -> b
    $ Payee
    p)
                 , [Char] -> Doc -> Doc
    label [Char]
    "Addr2" (([Char] -> Doc) -> Maybe [Char] -> Doc
    forall a. (a -> Doc) -> Maybe a -> Doc
    pMaybe [Char] -> Doc
    text (Maybe [Char] -> Doc) -> (Payee -> Maybe [Char]) -> Payee -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Payee -> Maybe [Char]
    peADDR2 (Payee -> Doc) -> Payee -> Doc
    forall a b. (a -> b) -> a -> b
    $ Payee
    p)
                 , [Char] -> Doc -> Doc
    label [Char]
    "Addr3" (([Char] -> Doc) -> Maybe [Char] -> Doc
    forall a. (a -> Doc) -> Maybe a -> Doc
    pMaybe [Char] -> Doc
    text (Maybe [Char] -> Doc) -> (Payee -> Maybe [Char]) -> Payee -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Payee -> Maybe [Char]
    peADDR3 (Payee -> Doc) -> Payee -> Doc
    forall a b. (a -> b) -> a -> b
    $ Payee
    p)
                 , [Char] -> Doc -> Doc
    label [Char]
    "City" ([Char] -> Doc
    text ([Char] -> Doc) -> (Payee -> [Char]) -> Payee -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Payee -> [Char]
    peCITY (Payee -> Doc) -> Payee -> Doc
    forall a b. (a -> b) -> a -> b
    $ Payee
    p)
                 , [Char] -> Doc -> Doc
    label [Char]
    "State" ([Char] -> Doc
    text ([Char] -> Doc) -> (Payee -> [Char]) -> Payee -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Payee -> [Char]
    peSTATE (Payee -> Doc) -> Payee -> Doc
    forall a b. (a -> b) -> a -> b
    $ Payee
    p)
                 , [Char] -> Doc -> Doc
    label [Char]
    "Postal" ([Char] -> Doc
    text ([Char] -> Doc) -> (Payee -> [Char]) -> Payee -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Payee -> [Char]
    pePOSTALCODE (Payee -> Doc) -> Payee -> Doc
    forall a b. (a -> b) -> a -> b
    $ Payee
    p)
                 , [Char] -> Doc -> Doc
    label [Char]
    "Country" (([Char] -> Doc) -> Maybe [Char] -> Doc
    forall a. (a -> Doc) -> Maybe a -> Doc
    pMaybe [Char] -> Doc
    text (Maybe [Char] -> Doc) -> (Payee -> Maybe [Char]) -> Payee -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Payee -> Maybe [Char]
    peCOUNTRY (Payee -> Doc) -> Payee -> Doc
    forall a b. (a -> b) -> a -> b
    $ Payee
    p)
                 , [Char] -> Doc -> Doc
    label [Char]
    "Phone" ([Char] -> Doc
    text ([Char] -> Doc) -> (Payee -> [Char]) -> Payee -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Payee -> [Char]
    pePHONE (Payee -> Doc) -> Payee -> Doc
    forall a b. (a -> b) -> a -> b
    $ Payee
    p)
                 ]

    pTransaction :: Transaction -> Doc
    pTransaction :: Transaction -> Doc
    pTransaction Transaction
    a = Doc -> Int -> Doc -> Doc
    hang Doc
    "Transaction:" Int
    2 Doc
    ls
      where
        ls :: Doc
    ls = [Doc] -> Doc
    sep [ [Char] -> Doc -> Doc
    label [Char]
    "TRNTYPE" ([Char] -> Doc
    text ([Char] -> Doc) -> (Transaction -> [Char]) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . TrnType -> [Char]
    forall a. Show a => a -> [Char]
    show (TrnType -> [Char])
    -> (Transaction -> TrnType) -> Transaction -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> TrnType
    txTRNTYPE (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "DTPOSTED" ([Char] -> Doc
    text ([Char] -> Doc) -> (Transaction -> [Char]) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ZonedTime -> [Char]
    forall a. Show a => a -> [Char]
    show (ZonedTime -> [Char])
    -> (Transaction -> ZonedTime) -> Transaction -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> ZonedTime
    txDTPOSTED (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "DTUSER" ([Char] -> Doc
    text ([Char] -> Doc) -> (Transaction -> [Char]) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Maybe ZonedTime -> [Char]
    forall a. Show a => a -> [Char]
    show (Maybe ZonedTime -> [Char])
    -> (Transaction -> Maybe ZonedTime) -> Transaction -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> Maybe ZonedTime
    txDTUSER (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "DTAVAIL" ([Char] -> Doc
    text ([Char] -> Doc) -> (Transaction -> [Char]) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Maybe ZonedTime -> [Char]
    forall a. Show a => a -> [Char]
    show (Maybe ZonedTime -> [Char])
    -> (Transaction -> Maybe ZonedTime) -> Transaction -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> Maybe ZonedTime
    txDTAVAIL (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "TRNAMT" ([Char] -> Doc
    text ([Char] -> Doc) -> (Transaction -> [Char]) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> [Char]
    txTRNAMT (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "FITID" ([Char] -> Doc
    text ([Char] -> Doc) -> (Transaction -> [Char]) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> [Char]
    txFITID (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "CORRECTFITID"
                   (([Char] -> Doc) -> Maybe [Char] -> Doc
    forall a. (a -> Doc) -> Maybe a -> Doc
    pMaybe [Char] -> Doc
    text (Maybe [Char] -> Doc)
    -> (Transaction -> Maybe [Char]) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> Maybe [Char]
    txCORRECTFITID (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "CORRECTACTION"
                   ([Char] -> Doc
    text ([Char] -> Doc) -> (Transaction -> [Char]) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Maybe CorrectAction -> [Char]
    forall a. Show a => a -> [Char]
    show (Maybe CorrectAction -> [Char])
    -> (Transaction -> Maybe CorrectAction) -> Transaction -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> Maybe CorrectAction
    txCORRECTACTION (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "SRVRTID" (([Char] -> Doc) -> Maybe [Char] -> Doc
    forall a. (a -> Doc) -> Maybe a -> Doc
    pMaybe [Char] -> Doc
    text (Maybe [Char] -> Doc)
    -> (Transaction -> Maybe [Char]) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> Maybe [Char]
    txSRVRTID (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "CHECKNUM" (([Char] -> Doc) -> Maybe [Char] -> Doc
    forall a. (a -> Doc) -> Maybe a -> Doc
    pMaybe [Char] -> Doc
    text (Maybe [Char] -> Doc)
    -> (Transaction -> Maybe [Char]) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> Maybe [Char]
    txCHECKNUM (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "REFNUM" (([Char] -> Doc) -> Maybe [Char] -> Doc
    forall a. (a -> Doc) -> Maybe a -> Doc
    pMaybe [Char] -> Doc
    text (Maybe [Char] -> Doc)
    -> (Transaction -> Maybe [Char]) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> Maybe [Char]
    txREFNUM (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "SIC" (([Char] -> Doc) -> Maybe [Char] -> Doc
    forall a. (a -> Doc) -> Maybe a -> Doc
    pMaybe [Char] -> Doc
    text (Maybe [Char] -> Doc)
    -> (Transaction -> Maybe [Char]) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> Maybe [Char]
    txSIC (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "PAYEEID" (([Char] -> Doc) -> Maybe [Char] -> Doc
    forall a. (a -> Doc) -> Maybe a -> Doc
    pMaybe [Char] -> Doc
    text (Maybe [Char] -> Doc)
    -> (Transaction -> Maybe [Char]) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> Maybe [Char]
    txPAYEEID (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "PAYEEINFO"
                   ((Either [Char] Payee -> Doc) -> Maybe (Either [Char] Payee) -> Doc
    forall a. (a -> Doc) -> Maybe a -> Doc
    pMaybe (([Char] -> Doc) -> (Payee -> Doc) -> Either [Char] Payee -> Doc
    forall a b. (a -> Doc) -> (b -> Doc) -> Either a b -> Doc
    pEither [Char] -> Doc
    text ([Char] -> Doc
    text ([Char] -> Doc) -> (Payee -> [Char]) -> Payee -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Payee -> [Char]
    forall a. Show a => a -> [Char]
    show)) (Maybe (Either [Char] Payee) -> Doc)
    -> (Transaction -> Maybe (Either [Char] Payee))
    -> Transaction
    -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> Maybe (Either [Char] Payee)
    txPayeeInfo (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "ACCOUNTTO"
                   ((Doc -> Doc) -> Maybe Doc -> Doc
    forall a. (a -> Doc) -> Maybe a -> Doc
    pMaybe Doc -> Doc
    forall a. a -> a
    id (Maybe Doc -> Doc)
    -> (Transaction -> Maybe Doc) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Either BankAcctTo CCAcctTo -> Doc)
    -> Maybe (Either BankAcctTo CCAcctTo) -> Maybe Doc
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ([Char] -> Doc
    text ([Char] -> Doc)
    -> (Either BankAcctTo CCAcctTo -> [Char])
    -> Either BankAcctTo CCAcctTo
    -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Either BankAcctTo CCAcctTo -> [Char]
    forall a. Show a => a -> [Char]
    show)
                              (Maybe (Either BankAcctTo CCAcctTo) -> Maybe Doc)
    -> (Transaction -> Maybe (Either BankAcctTo CCAcctTo))
    -> Transaction
    -> Maybe Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> Maybe (Either BankAcctTo CCAcctTo)
    txAccountTo (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "MEMO" (([Char] -> Doc) -> Maybe [Char] -> Doc
    forall a. (a -> Doc) -> Maybe a -> Doc
    pMaybe [Char] -> Doc
    text (Maybe [Char] -> Doc)
    -> (Transaction -> Maybe [Char]) -> Transaction -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> Maybe [Char]
    txMEMO (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 , [Char] -> Doc -> Doc
    label [Char]
    "CURRENCY"
                   ((Either Currency OrigCurrency -> Doc)
    -> Maybe (Either Currency OrigCurrency) -> Doc
    forall a. (a -> Doc) -> Maybe a -> Doc
    pMaybe ([Char] -> Doc
    text ([Char] -> Doc)
    -> (Either Currency OrigCurrency -> [Char])
    -> Either Currency OrigCurrency
    -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Either Currency OrigCurrency -> [Char]
    forall a. Show a => a -> [Char]
    show) (Maybe (Either Currency OrigCurrency) -> Doc)
    -> (Transaction -> Maybe (Either Currency OrigCurrency))
    -> Transaction
    -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Transaction -> Maybe (Either Currency OrigCurrency)
    txCurrency (Transaction -> Doc) -> Transaction -> Doc
    forall a b. (a -> b) -> a -> b
    $ Transaction
    a)
                 ]

    pTag :: Tag -> Doc
    pTag :: Tag -> Doc
    pTag (Tag [Char]
    n Either [Char] [Tag]
    ei) = case Either [Char] [Tag]
    ei of
      Left [Char]
    d -> Doc
    "<" Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Doc
    text [Char]
    n Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> Doc
    ">" Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Doc
    text [Char]
    d
      Right [Tag]
    ts -> [Doc] -> Doc
    vcat ([Doc] -> Doc) -> [Doc] -> Doc
    forall a b. (a -> b) -> a -> b
    $ Doc
    "<" Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Doc
    text [Char]
    n Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> Doc
    ">"
                       Doc -> [Doc] -> [Doc]
    forall a. a -> [a] -> [a]
    : (Tag -> Doc) -> [Tag] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (Int -> Doc -> Doc
    nest Int
    2 (Doc -> Doc) -> (Tag -> Doc) -> Tag -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Tag -> Doc
    pTag) [Tag]
    ts
                       [Doc] -> [Doc] -> [Doc]
    forall a. [a] -> [a] -> [a]
    ++ [Doc
    "</" Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Doc
    text [Char]
    n Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> Doc
    ">"]

    pHeader :: OFXHeader -> Doc
    pHeader :: OFXHeader -> Doc
    pHeader (OFXHeader [Char]
    t [Char]
    v) = [Char] -> Doc
    text [Char]
    t Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> Doc
    ": " Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Doc
    text [Char]
    v

    pFile :: OFXFile -> Doc
    pFile :: OFXFile -> Doc
    pFile (OFXFile [OFXHeader]
    hs Tag
    t)
      = Doc
    "OFX file:"
      Doc -> Doc -> Doc
    $$ Int -> Doc -> Doc
    nest Int
    2 ([Doc] -> Doc
    vcat [ [Doc] -> Doc
    pList ([Doc] -> Doc) -> ([OFXHeader] -> [Doc]) -> [OFXHeader] -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (OFXHeader -> Doc) -> [OFXHeader] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map OFXHeader -> Doc
    pHeader ([OFXHeader] -> Doc) -> [OFXHeader] -> Doc
    forall a b. (a -> b) -> a -> b
    $ [OFXHeader]
    hs
                       , Doc
    forall a. Monoid a => a
    mempty
                       , Tag -> Doc
    pTag Tag
    t ])

    pEither :: (a -> Doc) -> (b -> Doc) -> Either a b -> Doc
    pEither :: forall a b. (a -> Doc) -> (b -> Doc) -> Either a b -> Doc
    pEither a -> Doc
    fa b -> Doc
    fb = (a -> Doc) -> (b -> Doc) -> Either a b -> Doc
    forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
    either (\a
    l -> Doc
    "Left" Doc -> Doc -> Doc
    <+> Doc -> Doc
    parens (a -> Doc
    fa a
    l))
                           (\b
    r -> Doc
    "Right" Doc -> Doc -> Doc
    <+> Doc -> Doc
    parens (b -> Doc
    fb b
    r))

    pMaybe :: (a -> Doc) -> Maybe a -> Doc
    pMaybe :: forall a. (a -> Doc) -> Maybe a -> Doc
    pMaybe a -> Doc
    f = Doc -> (a -> Doc) -> Maybe a -> Doc
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Doc
    "Nothing" (\a
    x -> Doc
    "Just" Doc -> Doc -> Doc
    <+> Doc -> Doc
    parens (a -> Doc
    f a
    x))

    pList :: [Doc] -> Doc
    pList :: [Doc] -> Doc
    pList [Doc]
    ds = case [Doc]
    ds of
      [] -> Doc
    "[]"
      Doc
    x:[] -> Doc -> Doc
    brackets Doc
    x
      Doc
    x:[Doc]
    xs -> [Doc] -> Doc
    sep ([Doc] -> Doc) -> [Doc] -> Doc
    forall a b. (a -> b) -> a -> b
    $ Doc -> Int -> Doc -> Doc
    hang Doc
    "[" Int
    2 Doc
    x
                  Doc -> [Doc] -> [Doc]
    forall a. a -> [a] -> [a]
    : (Doc -> Doc) -> [Doc] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (\Doc
    d -> Doc -> Int -> Doc -> Doc
    hang Doc
    "," Int
    2 Doc
    d) [Doc]
    xs
                  [Doc] -> [Doc] -> [Doc]
    forall a. [a] -> [a] -> [a]
    ++ [ Doc
    "]" ]

    label :: String -> Doc -> Doc
    label :: [Char] -> Doc -> Doc
    label [Char]
    s = Doc -> Int -> Doc -> Doc
    hang ([Char] -> Doc
    text ([Char]
    s [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    ":")) ([Char] -> Int
    forall a. [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [Char]
    s Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    2)

    pExceptional
      :: (e -> Doc)
      -> (a -> Doc)
      -> Either e a
      -> Doc
    pExceptional :: forall a b. (a -> Doc) -> (b -> Doc) -> Either a b -> Doc
    pExceptional e -> Doc
    fe a -> Doc
    fa =
      (e -> Doc) -> (a -> Doc) -> Either e a -> Doc
    forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
    either (\e
    e -> Doc -> Int -> Doc -> Doc
    hang Doc
    "Exception:" Int
    2 (Doc -> Doc) -> Doc -> Doc
    forall a b. (a -> b) -> a -> b
    $ Doc -> Doc
    parens (e -> Doc
    fe e
    e))
             (\a
    g -> Doc -> Int -> Doc -> Doc
    hang Doc
    "Success:" Int
    2 (Doc -> Doc) -> Doc -> Doc
    forall a b. (a -> b) -> a -> b
    $ Doc -> Doc
    parens (a -> Doc
    fa a
    g))

    -- # Running Parsers

    -- | Parses an input file.  Returns either an error message or the
    -- resulting 'OFXFile'.
    parseOfxFile :: String -> Err OFXFile
    parseOfxFile :: [Char] -> Err OFXFile
    parseOfxFile = (ParseError -> Err OFXFile)
    -> (OFXFile -> Err OFXFile)
    -> Either ParseError OFXFile
    -> Err OFXFile
    forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
    either ([Char] -> Err OFXFile
    forall a b. a -> Either a b
    Left ([Char] -> Err OFXFile)
    -> (ParseError -> [Char]) -> ParseError -> Err OFXFile
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ParseError -> [Char]
    forall a. Show a => a -> [Char]
    show) (OFXFile -> Err OFXFile
    forall a b. b -> Either a b
    Right (OFXFile -> Err OFXFile)
    -> (OFXFile -> OFXFile) -> OFXFile -> Err OFXFile
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . OFXFile -> OFXFile
    forall a. a -> a
    id) (Either ParseError OFXFile -> Err OFXFile)
    -> ([Char] -> Either ParseError OFXFile) -> [Char] -> Err OFXFile
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Parser OFXFile -> [Char] -> [Char] -> Either ParseError OFXFile
    forall s t a.
    Stream s Identity t =>
    Parsec s () a -> [Char] -> s -> Either ParseError a
    parse Parser OFXFile
    ofxFile [Char]
    ""

    -- | Parses an OFX file and gets the list of 'Transaction'.
    parseTransactions :: String -> Err [Transaction]
    parseTransactions :: [Char] -> Err [Transaction]
    parseTransactions = OFXFile -> Err [Transaction]
    transactions (OFXFile -> Err [Transaction])
    -> ([Char] -> Err OFXFile) -> [Char] -> Err [Transaction]
    forall (m :: * -> *) b c a.
    Monad m =>
    (b -> m c) -> (a -> m b) -> a -> m c
    <=< [Char] -> Err OFXFile
    parseOfxFile

    -- | Loads an OFX file from disk, parses it, and returns the
    -- resulting 'OFXFile'.  Uses 'fail' if the parse fails.
    loadOfxFile :: FilePath -> IO OFXFile
    loadOfxFile :: [Char] -> IO OFXFile
    loadOfxFile [Char]
    fp = do
      [Char]
    txt <- [Char] -> IO [Char]
    readFile [Char]
    fp
      case [Char] -> Err OFXFile
    parseOfxFile [Char]
    txt of
        Left [Char]
    e -> [Char] -> IO OFXFile
    forall a. [Char] -> IO a
    forall (m :: * -> *) a. MonadFail m => [Char] -> m a
    fail [Char]
    e
        Right OFXFile
    g -> OFXFile -> IO OFXFile
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return OFXFile
    g

    -- | Loads an OFX file from disk, parses it, and returns the resulting list of
    -- 'Transaction'.  Uses 'fail' if the parse fails.
    loadTransactions :: FilePath -> IO [Transaction]
    loadTransactions :: [Char] -> IO [Transaction]
    loadTransactions [Char]
    fp = do
      [Char]
    txt <- [Char] -> IO [Char]
    readFile [Char]
    fp
      case [Char] -> Err [Transaction]
    parseTransactions [Char]
    txt of
        Left [Char]
    e -> [Char] -> IO [Transaction]
    forall a. [Char] -> IO a
    forall (m :: * -> *) a. MonadFail m => [Char] -> m a
    fail [Char]
    e
        Right [Transaction]
    g -> [Transaction] -> IO [Transaction]
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return [Transaction]
    g

    -- # Parsing and pretty printing

    -- | Parses an input file to an OfxFile.  Returns a pretty-printed
    -- string with the results of the parse.
    prettyRenderOfxFile
      :: String
      -- ^ File contents to parse
      -> String
      -- ^ Pretty printed result of rending the result of the parse, which
      -- is either an error message or an 'OFXFile'.
    prettyRenderOfxFile :: ShowS
    prettyRenderOfxFile
      = Doc -> [Char]
    render
      (Doc -> [Char]) -> ([Char] -> Doc) -> ShowS
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([Char] -> Doc) -> (OFXFile -> Doc) -> Err OFXFile -> Doc
    forall a b. (a -> Doc) -> (b -> Doc) -> Either a b -> Doc
    pExceptional [Char] -> Doc
    text OFXFile -> Doc
    pFile
      (Err OFXFile -> Doc) -> ([Char] -> Err OFXFile) -> [Char] -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Err OFXFile
    parseOfxFile

    -- | Parses an input file to an OfxFile, and then to a list of
    -- 'Transaction'.  Returns a pretty-printed string with the results.
    prettyRenderTransactions
      :: String
      -- ^ File contents to parse
      -> String
      -- ^ Pretty printed result of rendering the result of the parse,
      -- which is either an error message or a list of 'Transaction'.
    prettyRenderTransactions :: ShowS
    prettyRenderTransactions
      = Doc -> [Char]
    render
      (Doc -> [Char]) -> ([Char] -> Doc) -> ShowS
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([Char] -> Doc)
    -> ([Transaction] -> Doc) -> Err [Transaction] -> Doc
    forall a b. (a -> Doc) -> (b -> Doc) -> Either a b -> Doc
    pExceptional [Char] -> Doc
    text ([Doc] -> Doc
    pList ([Doc] -> Doc) -> ([Transaction] -> [Doc]) -> [Transaction] -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Transaction -> Doc) -> [Transaction] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Transaction -> Doc
    pTransaction)
      (Err [Transaction] -> Doc)
    -> ([Char] -> Err [Transaction]) -> [Char] -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Err [Transaction]
    parseTransactions