From 6d3c89c8a6ac8f57c00d85cac1e581ea9dcb9f01 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Tue, 2 Jun 2015 00:09:05 +0200 Subject: [PATCH] Improve docs Add images and stuff --- src/Data/Number/Functions.hs | 8 ++++---- src/Data/Number/Internal.hs | 11 ++++++++--- src/Data/Number/Types.hs | 16 +++++++++++++--- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/Data/Number/Functions.hs b/src/Data/Number/Functions.hs index ca2ea1f..6ab8446 100644 --- a/src/Data/Number/Functions.hs +++ b/src/Data/Number/Functions.hs @@ -40,26 +40,26 @@ toList (x:|xs) = x : toList xs -- | The infinite continued fraction whose terms are naturals numbers -- --- \[0, 1, 2, 3, 4,...\] = 0.6977746... +-- <> σ :: Number σ = σ' 0 where σ' n = n :| σ' (succ n) -- | The golden ratio -- --- φ = (1 + √5)/2 = 1.6180339... +-- <> φ :: Number φ = 1 :| φ -- | Pi: the ratio of a circle's circumference to its diameter -- --- π = 3.1415926... +-- <> π :: Number π = toNumber pi -- | Euler's number: the base of the natural logarithm -- --- e = 2.7182818... +-- <> e :: Number e = fmap a σ where a n | p == 0 = 2*q diff --git a/src/Data/Number/Internal.hs b/src/Data/Number/Internal.hs index a29b759..87abc4a 100644 --- a/src/Data/Number/Internal.hs +++ b/src/Data/Number/Internal.hs @@ -1,6 +1,7 @@ -- | Data.Number internals module Data.Number.Internal -( operator +( Matrix +, operator , cut , first , rest @@ -18,8 +19,12 @@ type Matrix = (Whole, Whole, Whole, Whole, Whole, Whole, Whole, Whole) -- | Continued fraction operator (implements Gosper's arithmetics) -- -- Given two 'Number' @x@, @y@ and the operator matrix --- @\@ --- calculates @z = (a + bx + cy + dxy) / (e + fx + gy + hxy)@ +-- +-- <> +-- +-- calculates +-- +-- <> -- -- See for a complete -- explanation. diff --git a/src/Data/Number/Types.hs b/src/Data/Number/Types.hs index cf50ceb..846d95b 100644 --- a/src/Data/Number/Types.hs +++ b/src/Data/Number/Types.hs @@ -5,11 +5,21 @@ import Data.Number.Peano infixr 5 :| -- | ==Continued fraction type --- represents a simple continued fraction of the form: --- @[a0, a1, a2,...] = a0 + 1\/(a1 + 1\/(a2 + 1\/...))@ +-- Represents a simple continued fraction of the form: -- --- == /Cons/ operator +-- <> +-- +-- Supports Haskell arithmetic operators though the use of the 'operator' +-- function is to be preferred since provide shortcuts to calculations. +-- +-- It can be an infinite sequence. Be careful with functions like @show@ +-- and @precision@: they may not terminate. +-- +-- === Cons operator -- @n :| x @ equivalent to @n@ + 1/@x@ +-- +-- === Negate operator +-- @M x @ equivalent to @-x@ data Continued a = M (Continued a) -- ^Negative number | a :| (Continued a) -- ^Positive number