mixed-types-num

Alternative Prelude with numeric and logic expressions typed bottom-up

https://github.com/michalkonecny/mixed-types-num#readme

Version on this page:0.5.0.0
LTS Haskell 23.25:0.6.2
Stackage Nightly 2025-06-18:0.6.2
Latest on Hackage:0.6.2

See all snapshots mixed-types-num appears in

BSD-3-Clause licensed by Michal Konecny
Maintained by [email protected]
This version can be pinned in stack with:mixed-types-num-0.5.0.0@sha256:08c88385aed96e6d3950dfa9b1dac0dcf8ea6be2c954ba08236e1bfb83ebe2e8,3212

Module documentation for 0.5.0.0

  • Data
    • Data.Convertible
      • Data.Convertible.Base
      • Data.Convertible.Instances
        • Data.Convertible.Instances.Num
      • Data.Convertible.Utils
  • MixedTypesNumPrelude
  • Numeric
    • Numeric.MixedTypes
      • Numeric.MixedTypes.AddSub
      • Numeric.MixedTypes.Bool
      • Numeric.MixedTypes.Complex
      • Numeric.MixedTypes.Div
      • Numeric.MixedTypes.Elementary
      • Numeric.MixedTypes.Eq
      • Numeric.MixedTypes.Field
      • Numeric.MixedTypes.Kleenean
      • Numeric.MixedTypes.Literals
      • Numeric.MixedTypes.MinMaxAbs
      • Numeric.MixedTypes.Ord
      • Numeric.MixedTypes.Power
      • Numeric.MixedTypes.PreludeHiding
      • Numeric.MixedTypes.Reduce
      • Numeric.MixedTypes.Ring
      • Numeric.MixedTypes.Round
  • Utils
    • Utils.TH
      • Utils.TH.DeclForTypes
    • Utils.Test
      • Utils.Test.EnforceRange

mixed-types-num

This package provides a version of Prelude where unary and binary operations such as not, +, == have their result type derived from the parameter type(s) and thus supports mixed-type arithmetic and comparisons.

Partial operations such as division, sqrt and power do not throw exceptions even when errors such as division by zero occur. Instead, these errors are propagated bottom-up in a bespoke error-accumulating functor from package collect-errors.

This library (as well as collect-errors) arose while developing the AERN2 library for interval and exact real computation. Certain aspects are specifically tailored for interval or exact real arithmetics, including three-valued numerical comparisons and distinguishing potential and certain errors.

See module MixedTypesNumPrelude for further documentation.

Hackage page including Haddock

Changes

mixed-types-num change log

  • v 0.5.0 2021-04-13

    • use package collect-errors with a much simpler CN wrapper
    • replace Maybe Bool by Kleenean (a new type)
    • remove very long type constraints in specifications using PartialTypeSignatures
  • v 0.4.1 2021-01-21

    • add hasErrorCE and hasErrorCN for testing if CE/CN values contain errors
  • v 0.4.0.2 2020-08-02

    • remove smallcheck version upper bound
    • update to cabal-version >= 1.10
  • v 0.4.0.1 2019-04-11

    • fix infinite loop in some conversions
  • v 0.4.0 2019-04-10

    • eliminated dependency on convertible, improving ghcjs compatibility
  • v 0.3.2 2019-01-08

    • added divI and mod
    • added enforceRange
    • used enforceRange in exp tests
  • v 0.3.1.5 2018-11-14

    • improved documentation
  • v 0.3.1.4 2017-12-06

    • removed upper bounds for dependencies
  • v 0.3.1.3 2017-08-22

    • fixed bound on base in test suite
  • v 0.3.1.2 2017-08-15

    • provided compatible versions of take, drop, length, replicate, splitAt
    • added missing mixed-type subtraction combination to Ring etc.
  • v 0.3.0.1 2017-08-01

    • improve package documentation in module MixedTypesNumPrelude
  • v 0.3 2017-08-01

    • renamed the main module to MixedTypesNumPrelude
    • much faster compilation
    • Ring and Field are now classes, not synonyms for large sets of constraints
    • many fixes in collect-error framework and its use in division and power
    • Overloaded if-then-else via -XRebindableSyntax
    • compiling with ghc 8.2.1
  • v 0.2.0.1

    • fix compilation bug in test suite
    • minor doc improvements
    • fix Complex instances of error-throwing division (/!)
  • v 0.2

    • new CollectErrors wrapper
    • CN, specialisation of CollectErrors to NumErrors
    • numerical partial operators (eg division) return a CN type
    • instances for Data.Complex
  • v 0.1

    • first release