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

Safe HaskellSafe-Infered




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.


Standard Haskell prelude

module Prelude

Compatibility classes

class Ring a => Num a whereSource

Haskell 98 compatibility class


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).


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

unchanged from Haskell 98


toRational :: a -> RationalSource

The rational equivalent of its real argument with full precision

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

Haskell 98 compatibility class


fromRational :: Rational -> aSource

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.

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

Integral numbers, supporting integer division.

Minimal complete definition: toInteger.


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

Unchanged classes

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

unchanged from Haskell 98


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

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

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

class Fractional a => Floating a whereSource

unchanged from Haskell 98


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

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.