yap-0.2: yet another prelude - a simplistic refactoring with algebraic classes

Portability portable provisional ross@soi.city.ac.uk Safe-Infered

Prelude.YAP

Description

A replacement for the standard Prelude, aiming to preserve compatibility for clients as far as possible. To use this module, you'll need to turn on `RebindableSyntax`, which also turns off the implicit import of the standard `Prelude`.

For greater backwards compatibility, this module hides the names of the classes `AbelianGroup`, `Ring`, `Field` and `EuclideanDomain`, and their new methods `zero`, `unit` and `associate`. To use those names, e.g. to define instances, you'll also need to import Data.YAP.Algebra.

Synopsis

module Prelude

## Compatibility classes

class Ring a => Num a whereSource

Methods

abs :: a -> aSource

Absolute value.

signum :: a -> aSource

Sign of a number. The functions `abs` and `signum` should satisfy the law:

``` abs x * signum x == x
```

For real numbers, the `signum` is either `-1` (negative), `0` (zero) or `1` (positive).

Instances

 Num Double Num Float Num Int Num Integer (Integral a, Integral a) => Num (Ratio a) RealFloat a => Num (Complex a)

class (Num a, Ord a) => Real a whereSource

Methods

toRational :: a -> RationalSource

The rational equivalent of its real argument with full precision

Instances

 Real Double Real Float Real Int Real Integer (Integral a, Integral a) => Real (Ratio a)

class (Num a, Field a) => Fractional a whereSource

Methods

Convert from `Rational`

A floating point numeric literal represents the application of the function `fromRational` to the appropriate value of type `Rational`, so such literals have type `(Field a) => a`.

Instances

 Fractional Double Fractional Float (Integral a, Integral a) => Fractional (Ratio a) RealFloat a => Fractional (Complex a)

class (Real a, Enum a, EuclideanDomain a) => Integral a whereSource

Integral numbers, supporting integer division.

Minimal complete definition: `toInteger`.

Methods

quot :: a -> a -> aSource

Integer division truncated toward zero

rem :: a -> a -> aSource

Integer remainder, satisfying

``` (x `quot` y)*y + (x `rem` y) == x
```

quotRem :: a -> a -> (a, a)Source

simultaneous `quot` and `rem`

toInteger :: a -> IntegerSource

Conversion to `Integer`

Instances

 Integral Int Integral Integer

## Unchanged classes

class (Real a, Fractional a) => RealFrac a whereSource

Methods

properFraction :: Integral b => a -> (b, a)Source

truncate, round :: Integral b => a -> bSource

ceiling, floor :: Integral b => a -> bSource

Instances

 RealFrac Double RealFrac Float (Integral a, Integral a) => RealFrac (Ratio a)

class Fractional a => Floating a whereSource

Methods

pi :: aSource

exp, sqrt, log :: a -> aSource

(**), logBase :: a -> a -> aSource

sin, tan, cos :: a -> aSource

asin, atan, acos :: a -> aSource

sinh, tanh, cosh :: a -> aSource

asinh, atanh, acosh :: a -> aSource

Instances

 Floating Double Floating Float RealFloat a => Floating (Complex a)

class (RealFrac a, Floating a) => RealFloat a whereSource

Instances

 RealFloat Double RealFloat Float

## Numeric functions

even, odd :: Integral a => a -> BoolSource

(^) :: (Ring a, Integral b) => a -> b -> aSource

raise a number to a non-negative integral power

(^^) :: (Field a, Integral b) => a -> b -> aSource

raise a number to an integral power

fromIntegral :: (Integral a, Ring b) => a -> bSource

General conversion from integral types, via the `Integer` type.

realToFrac :: (Real a, Fractional b) => a -> bSource

General conversion to fields, via the `Rational` type.