Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Installation and modules

This manual uses exchangealgebra-0.6.1.1 from Hackage. The examples assume that you can write Haskell programs and have Stack installed. They use GHC 9.10.3 with the Stackage snapshot lts-24.65.

The Algebra layer provides types for elements, bases, amounts, and finite sequences of terms. Its operations implement the redundant algebra. Accounting adds the interpretation of account titles and the debit and credit sides.

Add the package to a Stack project

In your project’s stack.yaml, select the snapshot and add the Hackage release as an extra dependency:

resolver: lts-24.65
packages:
- .
extra-deps:
- exchangealgebra-0.6.1.1

Add the library to your package.yaml dependencies. Preserve any other dependencies your program needs:

dependencies:
- base
- exchangealgebra == 0.6.1.1

extra-deps selects the package source for Stack; the dependency in package.yaml makes the library available to your program. Run stack build in the project directory to build the project and its dependencies. For a Cabal project, put exchangealgebra == 0.6.1.1 in the component’s build-depends instead.

Choose imports by layer

ExchangeAlgebra is a convenience module. It re-exports named selections of the Algebra API, account titles and classifications, accounting exchange operations, transfers and closing, trial-balance readouts, statement presentation, CSV and bookkeeping output, and money types. It does not re-export every public module. Import journal functions with import qualified ExchangeAlgebra.Journal as Journal and the operator with import ExchangeAlgebra.Journal ((.|)). Import matchesQuery directly from ExchangeAlgebra.Algebra.Element.

The module table lists public entry points in 0.6.1.1. Import a specific module to restrict the imported names to that part of the library.

LayerModules to importPurpose
AlgebraExchangeAlgebra.AlgebraElements, bases, the Alg type, and redundant-algebra operations.
AlgebraExchangeAlgebra.Algebra.Element, .Base, .Core, .ValueIndividual parts of the algebra; these abbreviated names share the prefix ExchangeAlgebra.Algebra.
AlgebraExchangeAlgebra.Algebra.Posting, ExchangeAlgebra.Algebra.TransferChecked term construction and generic transformations of bases.
JournalExchangeAlgebra.Journal, ExchangeAlgebra.Journal.TransferTerms indexed by notes, and transformations of those journals. Qualify function names shared with Algebra and import the operator .| unqualified.
AccountingExchangeAlgebra.Accounting, ExchangeAlgebra.Accounting.Account, ExchangeAlgebra.Accounting.ExchangeAccount titles, account classification, and debit and credit operations.
AccountingExchangeAlgebra.Accounting.TrialBalance, .Entries, .Closing, .Statements, .ConsolidationBookkeeping procedures; these abbreviated names share the prefix ExchangeAlgebra.Accounting.
IOExchangeAlgebra.IO.Input, ExchangeAlgebra.IO.Input.Admission, ExchangeAlgebra.IO.OutputExternal input, journal checks, and output.

The Simulation layer is outside the scope of this manual.

For the account divisions and side decompositions, ExchangeAlgebra.Accounting.Exchange provides ExBaseClass with whatDiv and whichSide, and Exchange with decL, decR, and balance. decL selects debit terms and decR selects credit terms. balance compares their exact totals before rounding. The journal example uses these functions through ExchangeAlgebra.

When the project builds, continue with Record a withdrawal.