packages feed

calculator-0.3.0.2: src/Calculator/Help.hs

{-# LANGUAGE CPP #-}

module Calculator.Help (help) where

--------------------------------------------------------------------------------

import           Calculator.Color            (bold)
import           Calculator.Prim.Definitions (binaryOps, defFuns, defVars,
                                              unaryOps)

--------------------------------------------------------------------------------

import           Data.List                   (intercalate, intersperse)

--------------------------------------------------------------------------------

help :: [String]
help = [ bold "Commands:"
       , "   :var x=pi          -- Binds x to pi"
       , "   :func f(x)=x+1     -- Binds f(x) to \"x + 1\""
       , "   :func f(x,y)=x+y   -- Binds f(x, y) to \"x + y\""
       , "   :reset             -- Reset variable and function bindings"
#ifdef PLOT
       , "   :plot              -- For plotting (detailed below)"
#endif
       , "   :show              -- Display all variable bindings"
       , "   :? or :help        -- Display this help message"
       , bold "Unary Operators: " ++ intersperse ' ' (map fst unaryOps)
       , bold "Binary Operators: " ++ intersperse ' ' (map fst binaryOps)
       , bold "Pre-defined variables: " ++ intercalate ", " (map fst defVars)
       , bold "Provided Functions: "
       , "   " ++ intercalate ", " (map fst defFuns)
       , bold "Spaces are ignored in most places"
       , "   :func f ( x ) = x + x + x     -- works"
       , " but not everywhere, e.g in commands"
       , "   : func ...                    -- doesn't work"
#ifdef PLOT
       , bold "Plotting: "
       , "   :plot f (0, 1)"
       , "   -- Plot a single argument function 'f' in range (0, 1)"
       , "   :plot f (0, 1) (1, 2)"
       , "   -- Plot a two argument function 'f' in range (0, 1)"
       , "   -- where the second argument can be varied between 1 and 2"
#endif
       ]

--------------------------------------------------------------------------------