-- | Definition of the continued fraction type
module Data.Number.Types where

import Data.Number.Peano

infixr 5 :| 
-- | ==Continued fraction type
-- Represents a simple continued fraction of the form:
--
-- <<https://i.imgur.com/RgNIDHQ.png>>
--
-- 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
  | E                  -- ^Zero
  deriving (Eq, Ord, Show, Read)

-- | Real numbers datatype (a continued fraction of naturals)
type Number = Continued Nat