hafar: Affine arithmetic library for Haskell

[ bsd3, library, numeric ] [ Propose Tags ]

Hafar is an affine arithmetic library for Haskell. It is an efficient way to work with ranges of values or imprecise values.

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],
Change log ChangeLog.md
Dependencies base (>=4.12 && <4.13), intervals (>=0.8 && <0.9), mtl (>=2.2 && <2.3) [details]
License BSD-3-Clause
Copyright 2019 Joosep Jääger
Author Joosep Jääger
Maintainer Joosep Jääger
Category Numeric
Home page https://github.com/Soupstraw/hafar#readme
Bug tracker https://github.com/Soupstraw/hafar/issues
Source repo head: git clone https://github.com/Soupstraw/hafar
Uploaded by j_jaager at 2020-04-14T12:45:35Z
Distributions NixOS:
Downloads 492 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-04-14 [all 1 reports]

Readme for hafar-

[back to package description]


Hafar is an implementation of affine arithmetic in haskell.


To build the library, simply run

# stack build

or if using cabal

# cabal install --only-dependencies
# cabal build


All operations with affine forms must be done inside the AFM monad.

import Numeric.Interval hiding (interval)

x1 = do
  a <- newFromInterval $ 4...6
  b <- newFromInterval $ 4...6
  return . interval $ a - b

evalAFM x1 -- evaluates to approximately -2 ... 2

x2 = do
  a <- newFromInterval $ 4...6
  return . interval $ a - a

evalAFM x2 -- evaluates to approximately 0 ... 0