constmathghcplugin alternatives and similar packages
Based on the "Compiler Plugin" category.
Alternatively, view constmathghcplugin alternatives based on common mentions on social networks and blogs.

inspectiontesting
Inspection Testing for Haskell 
strictghcplugin
Compiler plugin for making Haskell strict 
smuggler2
Minimise haskell imports, make exports explicit 
unrollghcplugin
Compiler plugin for loop unrolling 
BinderAnn
BinderAnn: Automated Reification of Source Annotations for Monadic EDSLs 
haskellstacktraceplugin
haskellstacktraceplugin 
cseghcplugin
Compiler plugin for common subexpression elimination
Deliver Cleaner and Safer Code  Right in Your IDE of Choice!
Do you think we are missing an alternative of constmathghcplugin or a related project?
README
GHC plugin for Constant Math
This plugin eliminates constant math expressions from Haskell source.
Using this plugin adds a compiler pass which replaces mathematical expressions on constant numeric values with the result of that expression. Supported expressions include:
 unary RealFloat functions (exp, log, sqrt, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh)
 unary Num functions (negate, abs, signum).
 fromRational
 (**)
Basic arithmetic expressions (addition, subtraction, multiplication, division) are already eliminated by existing GHC passes. This plugin is run multiple times during compilation, so the results of intermediate arithmetic eliminations are exposed to the constmath plugin, allowing chains of mathematical expressions to be completely eliminated.
Installation
Install the latest released version of the plugin from Hackage (requires GHC >= 7.4.1):
$ cabal install constmathghcplugin
Alternatively, git clone this repo and:
$ cabal install
Use
To use this plugin when building a Haskell source file, pass the following argument to GHC:
$ ghc fplugin ConstMath.Plugin foo.hs
To build a cabal package packagename:
$ cabal install ghcoptions="package constmathghcplugin fplugin ConstMath.Plugin" packagename
Note that you need to expose the constmathghcplugin package to ghc (using the package argument) as cabal will otherwise hide all packages not specified in packagename.cabal.
Options
Option arguments can be passed to the plugin with fpluginopt:
$ ghc fplugin ConstMath.Plugin fpluginopt=ConstMath.Plugin:ARG foo.hs
Currently available arguments are:
dry, dryrun
Don't make any substitutions, just report on matches
v,verbose
verbose output (default)
trace
very verbose output (useful for seeing the AST used for matching)
q, quiet
no output
Phase control
enabledefault
run a ConstMath pass after early simplifier passes
enablepostsimpl
run a ConstMath pass after every simplifier pass
enablealways
run a ConstMath pass after every compiler pass (expensive)
Inspecting the result
To see the resulting changes, compare the core produced. An excellent way to
view core is to cabal install ghccore
, a tool which runs ghc with options
to dump the core and the disassembled output in a pager with syntax
highlighting:
$ ghccore  O2 fplugin ConstMath.Plugin foo.hs
Alternatively, just run ghc directly and ask it to show you the core:
$ ghc fforcerecomp ddumpsimpl O2 fplugin ConstMath.Plugin foo.hs
For example, we generate a short file with a single math expression:
$ echo "module Main where main = print (1.0 / sqrt (2 * pi))" > foo.hs
Dumping the core produced by a normal optimized GHC build shows the sqrt will be evaluated at runtime:
$ ghc ddumpsimpl O2 foo.hs  grep sqrt
case GHC.Prim./## 1.0 (GHC.Prim.sqrtDouble# 6.283185307179586)
Note that GHC has already calculated the result of (2 * pi).
However, dumping the core produced by GHC with the additional const math pass shows that the call to sqrt has been removed:
$ ghc ddumpsimpl O2 fplugin ConstMath.Plugin foo.hs  grep c sqrt
0
Inspecting the core further show that the division has also been removed, and the result of the entire math expression will be directly written into the executable:
GHC.Float.$w$sformatRealFloat
GHC.Float.FFGeneric
(Data.Maybe.Nothing @ GHC.Types.Int)
0.3989422804014327
Tests
The source tree contains a set of tests, including the full numeric test suite imported from the GHC sources. To run the test suite:
$ cd tests
$ make
Alternatively, you can use the cabal test
framework:
$ cabal install enabletests
Join in
File bugs in the GitHub issue tracker.
Master git repository:
git clone https://github.com/kfish/constmathghcplugin.git
License
BSD3. See LICENSE
for terms of copyright and redistribution.
*Note that all licence references and agreements mentioned in the constmathghcplugin README section above
are relevant to that project's source code only.