Function +Data.Numeric
MPTC/FD generalisations of (.) and flip
Version 0.1.0
This package provides instances for functions (k -> a) of the classes Absolute, Algebraic, Differential, Field, Lattice, Monoid, Ring and Transcendental from the numeric-prelude package. An instance for Additive already comes with the original package.
If a has an instance for one of the classes, then (k -> a) has too. The instances do what you would expect. Values become constant functions:
> zero = const zero
Unary functions are composed:
> sin f = sin . f
Binary functions fan out the input and combine both results:
> f + g = \x -> f x + g x
You can either import them separately or import Data.Function.Instances.Algebra to get them all at once.
Version 0.1
If you program with Arrows you have two choices: Use the plain Arrow combinators, that are cumbersome to use, or use special Arrow syntax, that is built into all Haskell compilers and is still not very functional programming style. The arrow syntax still forces you to introduce temporary names, that you would not need in a functional notation.
Where you would write things like
> mix <<< (id &&& delay) <<< lowpass
using plain Arrow combinators, you can now write
> lowpass >>>= \x ->
> mix <<< (listen x &&& (delay <<< listen x))
where the (>>>=) resembles the monadic bind and allows you for shared access to an arrow result. Thus it can be used like a let.
Version 0.0
This library provides implementations of special mathematical functions and Chebyshev polynomials. These functions are often useful in statistical and numerical computing.
Version 0.1.1.1
ParserFunction provides utilities for parsing and evaluating mathematical expressions. The central parsing function in this package is stringToExpr, which parses a string-expression and returns a maybe expression tree. This tree is suitable for performing symbolic manipulation. Expressions can then be evaluated using the function evalExpr. If you wish to evaluate a string-expression without any intermediate operations, simply use the function evalString. Examples of these functions can be seen by viewing the source code of this module.
Version 0.0.8
Small and simple library for computing values of Theta functions. They're the special functions of two variables. Described very well at Wikipedia article with corresponding name. Library exports four theta-functions and a small helper to calculate their second parameter. Theta functions are functions of Complex variables, FYI.
Version 1.0.0
Example:
You have a pure function that may be giving you incorrect results.
> fib :: Int -> Int
> fib n | n < 2 = n
> | otherwise = fib (n-1) - fib (n-2)
>>> fib 3 0
Insert a call to traceFunction to aid with debugging.
> fib, fib' :: Int -> Int
> fib = traceFunction "fib" fib'
> fib' n | n < 2 = n
> | otherwise = fib (n-1) - fib (n-2)
Calls to your pure function now provide its parameters and result as debugging information.
>>> fib 3 fib 1 = 1 fib 0 = 0 fib 2 = 1 fib 1 = 1 fib 3 = 0 0
Hopefully this will help you home in on your bug.
Note that traceFunction works with functions of more than one parameter...
> traceElem :: Eq a => a -> [a] -> Bool
> traceElem = traceFunction "elem" elem
...and with "functions" of no parameters at all.
> alpha = traceFunction "Fine-structure constant" $
> e * e * c * mu0 / 2 / h
Parameters and results must implement the Show typeclass. As a special case, parameters may instead be functions, and are shown as an underscore (_).
>>> :set -XNoMonomorphismRestriction >>> let map' = traceFunction "map" map >>> map' (2 *) [1..3] map _ [1,2,3] = [2,4,6] [2,4,6]
KNOWN BUG: The resultant function is strict, even when the input function is non-strict in some of its parameters. In particular,
* if one of the parameters is error "foo", the return value when the resultant function call is evaluated will be error "foo"; no trace message will be output
* if one of the parameters doesn't terminate when evaluated, the resultant function call will not terminate when evaluated either; no trace message will be output
Version 0.1
This package supports emulation of type-level functions using defunctionalization. All functions whose domain is a subkind of * and whose codomain is * itself can be represented.
For detailed information, please refer to Subsection 3.2 of the paper Generic Record Combinators with Static Type Checking.
Version 0.2.0.3