-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Terminal-based graphing via ANSI and Unicode
--
-- Ansigraph is an ultralightweight terminal-based graphing utility. It
-- uses Unicode characters and ANSI escape codes to display and animate
-- colored graphs of vectors/functions in real and complex variables.
--
-- This functionality is provided by a Graphable type class, whose
-- method graphWith draws a graph at the terminal. Another
-- function animateWith takes a list of Graphable elements and
-- displays an animation by rendering them in sequence. Both of these
-- functions take an options record as an argument. The graph and
-- animate functions are defined to use the default options, and
-- the user can define similar functions based on their own settings.
--
-- There are two main ways to use the package. Importing
-- System.Console.Ansigraph provides all the functionality we
-- typically use. This includes the FlexibleInstances extension,
-- which makes it marginally more convenient to use graphing functions by
-- allowing instances like 'Graphable [Double]'.
--
-- If you want to use the package without activating
-- FlexibleInstances then you can import
-- System.Console.Ansigraph.Core, which provides everything except
-- these instances. Then you must use one of a few newtype wrappers,
-- namely: Graph, PosGraph, CGraph, Mat,
-- CMat. These wrappers are also available from the standard
-- Ansigraph module.
--
-- The System.Console.Ansigraph.Examples module contains examples
-- of all the graph types, and also shows the available ANSI colors.
@package ansigraph
@version 0.2.0.0
-- | This module provides the core functionality of the ansigraph package:
-- terminal-based graphing for vectors and matrices of real and complex
-- numbers.
--
-- This is implemented via a Graphable type class.
--
-- Ansigraph is intended to be used in on of two ways:
--
--
-- - By importing System.Console.Ansigraph. This provides
-- all the functionality we typically use, including the
-- FlexibleInstances extension which makes it easier to use graphing
-- functions by allowing instances like 'Graphable [Double]'.
-- - By directly importing System.Console.Ansigraph.Core,
-- which does not activate FlexibleInstances but includes everything else
-- provided by the other module. This just means you must use one of a
-- few newtype wrappers, namely: Graph, PosGraph,
-- CGraph, Mat, CMat. They are also available from
-- the standard module.
--
module System.Console.Ansigraph.Core
-- | Things that ansigraph knows how to render at the terminal are
-- instances of this class.
--
-- In general, when ANSI codes are involved, a graphWith method
-- should fush stdout when finished, and whenever codes are invoked to
-- i.e. change terminal colors. This is easily handled by defining it in
-- terms of colorStr and colorStrLn.
--
-- The graphHeight function specifies how many vertical lines a
-- graph occupies and is needed for animations to work properly
class Graphable a
-- | Render a graph to standard output.
graphWith :: Graphable a => GraphSettings -> a -> IO ()
-- | The number of vertical lines a graph occupies.
graphHeight :: Graphable a => a -> Int
-- | Invokes the Graphable type class method graphWith with
-- the default GraphSettings record, graphDefaults.
graph :: Graphable a => a -> IO ()
-- | Any list of a Graphable type can be made into an animation, by
-- graphing each element with a time delay and screen-clear after
-- each. GraphSettings are used to determine the time delta and
-- any coloring/scaling options.
animateWith :: Graphable a => GraphSettings -> [a] -> IO ()
-- | Perform animateWith using default options. Equivalent to
-- graphing each member of the supplied list with a short delay
-- and screen-clear after each.
animate :: Graphable a => [a] -> IO ()
-- | Like animate, only it does not leave the final frame of the
-- animation visible.
transientAnim :: Graphable a => [a] -> IO ()
-- | Like animateWith, only it does not leave the final frame of the
-- animation visible.
transientAnimWith :: Graphable a => GraphSettings -> [a] -> IO ()
-- | Record that holds graphing options.
data GraphSettings
GraphSettings :: AnsiColor -> AnsiColor -> AnsiColor -> AnsiColor -> AnsiColor -> AnsiColor -> Int -> GraphSettings
-- | Foreground color for real number component.
[realColor] :: GraphSettings -> AnsiColor
-- | Foreground color for imaginary number component.
[imagColor] :: GraphSettings -> AnsiColor
-- | Foreground color for negative real values. For matrix graphs only.
[realNegColor] :: GraphSettings -> AnsiColor
-- | Foreground color for negative imaginary values. For matrix graphs
-- only.
[imagNegColor] :: GraphSettings -> AnsiColor
-- | Background color for real number component.
[realBG] :: GraphSettings -> AnsiColor
-- | Background color for imaginary number component.
[imagBG] :: GraphSettings -> AnsiColor
-- | Framerate in FPS.
[framerate] :: GraphSettings -> Int
-- | Default graph settings.
graphDefaults :: GraphSettings
-- | Vivid Blue – used as the default real foreground color.
blue :: AnsiColor
-- | Vivid Magenta – used as the default foreground color for
-- imaginary graph component.
pink :: AnsiColor
-- | Vivid White – used as the default graph background color
-- for both real and imaginary graph components.
white :: AnsiColor
-- | Vivid Red – used as the default foreground color for
-- negative real component.
red :: AnsiColor
-- | Dull Green – used as the default foreground color for
-- negative imaginary component.
green :: AnsiColor
-- | A Coloring representing default terminal colors, i.e. two
-- Nothings.
noColoring :: Coloring
-- | ANSI colors are characterized by a Color and a
-- ColorIntensity.
data AnsiColor
AnsiColor :: ColorIntensity -> Color -> AnsiColor
[intensity] :: AnsiColor -> ColorIntensity
[color] :: AnsiColor -> Color
-- | Holds two Maybe AnsiColors representing foreground and
-- background colors for display via ANSI. Nothing means use the
-- default terminal color.
data Coloring
Coloring :: Maybe AnsiColor -> Maybe AnsiColor -> Coloring
[foreground] :: Coloring -> Maybe AnsiColor
[background] :: Coloring -> Maybe AnsiColor
-- | Helper constructor function for Coloring that takes straight
-- AnsiColors without Maybe.
mkColoring :: AnsiColor -> AnsiColor -> Coloring
-- | Easily create a Coloring by specifying the foreground
-- AnsiColor and no custom background.
fromFG :: AnsiColor -> Coloring
-- | Easily create a Coloring by specifying the background
-- AnsiColor and no custom foreground.
fromBG :: AnsiColor -> Coloring
-- | Projection retrieving foreground and background colors for real number
-- graphs in the form of a Coloring.
realColors :: GraphSettings -> Coloring
-- | Projection retrieving foreground and background colors for imaginary
-- component of complex number graphs in the form of a Coloring.
imagColors :: GraphSettings -> Coloring
-- | Retrieves a pair of Colorings for real and imaginary graph
-- components respectively.
colorSets :: GraphSettings -> (Coloring, Coloring)
-- | Swaps foreground and background colors within a Coloring.
invert :: Coloring -> Coloring
-- | The SGR command corresponding to a particular ConsoleLayer and
-- AnsiColor.
interpAnsiColor :: ConsoleLayer -> AnsiColor -> SGR
-- | Set the given AnsiColor on the given ConsoleLayer.
setColor :: ConsoleLayer -> AnsiColor -> IO ()
-- | Clear any SGR settings and then flush stdout.
clear :: IO ()
-- | Clear any SGR settings, flush stdout and print a new line.
clearLn :: IO ()
-- | Apply both foreground and background color contained in a
-- Coloring.
applyColoring :: Coloring -> IO ()
-- | Use a particular ANSI Coloring to print a string at the
-- terminal (without a new line), then clear all ANSI SGR codes and flush
-- stdout.
colorStr :: Coloring -> String -> IO ()
-- | Use a particular ANSI Coloring to print a string at the
-- terminal, then clear all ANSI SGR codes, flush stdout and print a new
-- line.
colorStrLn :: Coloring -> String -> IO ()
-- | Like colorStr but prints bold text.
boldStr :: Coloring -> String -> IO ()
-- | Like colorStrLn but prints bold text.
boldStrLn :: Coloring -> String -> IO ()
-- | Wrapper type for graph of a real vector/function.
newtype Graph
Graph :: [Double] -> Graph
[unGraph] :: Graph -> [Double]
-- | Wrapper type for graph of a complex vector/function.
newtype CGraph
CGraph :: [Complex Double] -> CGraph
[unCGraph] :: CGraph -> [Complex Double]
-- | Wrapper type for graph of a non-negative real vector/function.
newtype PosGraph
PosGraph :: [Double] -> PosGraph
[unPosGraph] :: PosGraph -> [Double]
-- | Wrapper type for graph of a real two-index vector/two-argument
-- function.
newtype Mat
Mat :: [[Double]] -> Mat
[unMat] :: Mat -> [[Double]]
-- | Wrapper type for graph of a complex two-index vector/two-argument
-- function.
newtype CMat
CMat :: [[Complex Double]] -> CMat
[unCMat] :: CMat -> [[Complex Double]]
-- | ANSI based display for positive real vectors. Primarily invoked via
-- graph, graphWith, animate,
-- animateWith.
displayPV :: GraphSettings -> [Double] -> IO ()
-- | ANSI based display for real vectors. Primarily invoked via
-- graph, graphWith, animate,
-- animateWith.
displayRV :: GraphSettings -> [Double] -> IO ()
-- | ANSI based display for complex vectors. Primarily invoked via
-- graph, graphWith, animate,
-- animateWith.
displayCV :: GraphSettings -> [Complex Double] -> IO ()
-- | Simple vector to String rendering that assumes positive input. Yields
-- String of Unicode chars representing graph bars varying in units of
-- 1/8. The IO display functions are preferable for most use
-- cases.
renderPV :: [Double] -> String
-- | Simple real vector rendering as a pair of strings. The IO
-- display functions are preferable for most use cases.
renderRV :: [Double] -> (String, String)
-- | Simple complex vector rendering as a pair of strings. The IO
-- display functions are preferable for most use cases.
renderCV :: [Complex Double] -> (String, String, String, String)
-- | Use ANSI coloring (specified by an GraphSettings) to visually
-- display a Real matrix.
displayMat :: GraphSettings -> [[Double]] -> IO ()
-- | Use ANSI coloring (specified by an GraphSettings) to visually
-- display a Complex matrix.
displayCMat :: GraphSettings -> [[Complex Double]] -> IO ()
-- | Given a matrix of Doubles, return the list of strings illustrating the
-- absolute value of each entry relative to the largest, via unicode
-- chars that denote a particular density. Used for testing purposes.
matShow :: [[Double]] -> [String]
-- | Display a graph of the supplied (non-negative) real vector.
posGraph :: [Double] -> IO ()
-- | Display an animation of the supplied list of (non-negative) real
-- vectors.
posAnim :: [[Double]] -> IO ()
instance System.Console.Ansigraph.Core.Graphable System.Console.Ansigraph.Core.Graph
instance System.Console.Ansigraph.Core.Graphable System.Console.Ansigraph.Core.CGraph
instance System.Console.Ansigraph.Core.Graphable System.Console.Ansigraph.Core.PosGraph
instance System.Console.Ansigraph.Core.Graphable System.Console.Ansigraph.Core.Mat
instance System.Console.Ansigraph.Core.Graphable System.Console.Ansigraph.Core.CMat
-- | This is the primary module to import for use of the ansigraph package,
-- which provides terminal-based graphing for vectors and matrices of
-- real and complex numbers.
--
-- This functionality is implemented via a Graphable type class.
--
-- Ansigraph is intended to be used in on of two ways:
--
--
-- - By importing System.Console.Ansigraph. This provides
-- all the functionality we typically use, including the
-- FlexibleInstances extension which makes it easier to use graphing
-- functions by allowing instances like 'Graphable [Double]'. It also
-- provides System.Console.AnsiGraph.Core which provides all the
-- core functionality. See the Haddock page for that module for more
-- details.
-- - By directly importing System.Console.Ansigraph.Core,
-- which does not activate FlexibleInstances but includes everything else
-- provided by the other module. This just means you must use one of a
-- few newtype wrappers, namely: Graph, PosGraph,
-- CGraph, Mat, CMat. They are also available from
-- the standard module.
--
module System.Console.Ansigraph
-- | A module that shows some simple examples demonstrating how to use the
-- package.
module System.Console.Ansigraph.Examples
-- | Run all of the demos in sequence.
demo :: IO ()
-- | Displays a legend showing color conventions for supported graph types.
legend :: IO ()
-- | Show all of the available AnsiColors with corresponding
-- ColorIntensity, Color pairs.
showColors :: IO ()
-- | Display an animation of the complex wave z(x,t) = exp(ix - it)
-- in some units.
waveDemoComplex :: IO ()
-- | Display an animation of the real function r(x,t) = cos(x-t) in
-- the standard style, i.e. with both positive and negative regions.
waveDemoReal :: IO ()
-- | Display an animation of the positive real function p(x,t) =
-- cos(x-t) + 1 in some units.
waveDemoPositive :: IO ()
-- | A complex wave vector, part of the graph of z(x,t) = exp(ix -
-- it) in some units.
wave :: [Complex Double]
-- | An example real matrix animation.
matDemoReal :: IO ()
-- | Shows an animation of an example time-dependent matrix formed from
-- Pauli matrices, called unitary. Specifically, it is the tensor
-- product of σz and σx exponentiated with different frequencies.
matDemoComplex :: IO ()
-- | An example of a time-dependent complex matrix.
unitary :: Double -> [[Complex Double]]