numhask: A numeric prelude

[ bsd3, library, math ] [ Propose Tags ]
Versions [RSS] 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4.0, 0.2.0.0, 0.2.1.0, 0.2.2.0, 0.2.3.0, 0.2.3.1, 0.3.0.0, 0.3.1, 0.4.0, 0.5.0, 0.6.0, 0.6.0.1, 0.6.0.2, 0.7.0.0, 0.7.1.0, 0.8.0.0, 0.8.1.0, 0.9.0.0, 0.10.0.0, 0.10.1.0, 0.10.1.1, 0.11.0.1, 0.11.0.2, 0.11.1.0, 0.12.0.0, 0.12.0.1, 0.12.0.2
Dependencies adjunctions (>=4.3 && <5), base (>=4.7 && <4.11), distributive (>=0.5 && <0.6), matrix (>=0.3.5.0 && <0.4), protolude (>=0.1 && <0.3), QuickCheck (>=2.8 && <3), singletons (>=2.2 && <3), vector (>=0.11 && <0.13) [details]
License BSD-3-Clause
Copyright Tony Day
Author Tony Day
Maintainer tonyday567@gmail.com
Category mathematics
Home page https://github.com/tonyday567/numhask
Source repo head: git clone https://github.com/tonyday567/numhask
Uploaded by tonyday567 at 2017-08-26T04:52:38Z
Distributions LTSHaskell:0.11.1.0, NixOS:0.11.1.0, Stackage:0.11.1.0
Reverse Dependencies 24 direct, 6 indirect [details]
Downloads 15432 total (119 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-08-26 [all 1 reports]

Readme for numhask-0.1.1

[back to package description]

numhask

Build Status Hackage lts nightly

A numeric prelude, providing a clean structure for numbers and operations that combine them.

This particular shed has been painted:

  • by providing separately named magma-derived classes for addition and multiplication, and then being symetrical in the treatment of the two heirarchies. A short magma structure is provided with the intention of supplying appropriate classes fro operators that are no addition nor multiplication, but this structure is not hooked up to the main classes.
  • to be as compatible as practical with the existing haskell ecosystem. Ints, Integers, Floats, Doubles and Complex are taken from base and given numhask instances, so they are also Num instances. Monoid and Semigroup are not used in numhask to maintain compatability.
  • as a replacement for anything in base that has a Num, Fractional or Real constraint.
  • with type-checked Vector and Matrix instances using Representable to build the shape and structure.
  • includes QuickCheck tests of the numeric laws implicit in the classes. This also includes tracking where laws are approximate or fail for non-exact numbers.
  • the usual operators (+) and (*) operators are reserved for commutative relationships, with plus and times being used for non-commutative ones.

Alternative color-schemes, stylistic flourishes and opines are welcome.

In summary, the library doesn't do anything fancy. But if having to define (*) when you just want a (+) offends your sensibilities, it may bring some sanity.

Representable numbers

Vector and Matrix objects are provided that:

  • are shape type-checked
  • are based on Representable instances
  • have inner and tensor product operators

These are experimental and await testing in the wild.

Usage

{-# LANGUAGE NoImplicitPrelude #-}
import Numhask.Prelude

'Numhask.Prelude' is designed as a drop-in replacement for Prelude and 'NoImplicitPrelude' is obligatory. Behind the scenes, the module wraps protolude.

See Examples for basic examples, and numhask-space for slightly heavier number crunching.