-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A minimalistic but extensible and precise calculator -- -- Hascal is both a simple but extendable calculator library for Haskell -- as well as a command-line program using this library. -- -- Hascal supports addition, subtraction, multiplication, division, -- exponentiation, and logarithm, while it's easy to add custom -- operators. -- -- Hascal also supports complex numbers. Hascal can work at an arbitrary -- precision. However, Hascal does not support parenthesis. @package hascal @version 3.0 -- | Hascal is a simple, minimalistic, tiny calculator library and program. -- --
-- >>> hascal 1+2-3*4/5^6?7 -- -1.7263530417152033 ---- -- Given a configuration, the hascal function similarly evaluates -- an expression of type String. In a Haskell interpreter like -- GHCI, type: -- --
-- >>> hascal def "1+2-3*4/5^6?7" -- Right (0.2736469582847967 :+ 0.0) ---- --
-- >>> hascal def "1++2" -- Left "Error at \"\"." --module Hascal -- | A configuration. def is the default configuration. data Config t Config :: [Operator t] -> [Constant t] -> Config t -- | A list of operators. The order in this list also determines the order -- of evaluation. [operators] :: Config t -> [Operator t] -- | A list of constants. [constants] :: Config t -> [Constant t] -- | A class for types with a default value. class Default a -- | The default value for this type. def :: Default a => a -- | Given a configuration and a String-expression, returns -- Either a String containing an error message; or a -- Complex number. hascal :: (Read t, RealFloat t) => Config t -> String -> Result t -- | Given a configuration and a String-expression, returns a -- String containing the error message or the resulting complex -- number. showHascal :: (Show t, Read t, RealFloat t) => Config t -> String -> String -- | Show a Complex number a little bit more human-readable by -- matching both the real and the imaginery part against zero and one. showNumber :: (Show t, RealFloat t) => Complex t -> String instance (GHC.Read.Read t, GHC.Float.RealFloat t) => Data.Default.Class.Default (Hascal.Config t)