https://wiki.haskell.org/api.php?action=feedcontributions&user=Bjorn&feedformat=atomHaskellWiki - User contributions [en]2020-07-08T05:40:11ZUser contributionsMediaWiki 1.27.4https://wiki.haskell.org/index.php?title=Avoiding_partial_functions&diff=62115Avoiding partial functions2017-09-04T04:03:31Z<p>Bjorn: Add reference to the safe library.</p>
<hr />
<div>There are several [[partial functions]] in the Haskell standard library.<br />
If you use them, you always risk to end up with an undefined.<br />
In this article we give some hints how to avoid them, leading to code that you can be more confident about.<br />
<br />
In addition to the below rewrites, many partial functions can be avoided by using variants from the [https://hackage.haskell.org/package/safe safe] library.<br />
<br />
For a partial function f the general pattern is:<br />
Wherever we write "check whether x is in the domain of f before computing f x",<br />
we replace it by combination of check and computation of f.<br />
<br />
== fromJust ==<br />
<br />
You should replace<br />
<haskell><br />
if isNothing mx<br />
then g<br />
else h (fromJust mx)<br />
</haskell><br />
by<br />
<haskell><br />
case mx of<br />
Nothing -> g<br />
Just x -> h x<br />
</haskell><br />
which is equivalent to<br />
<haskell><br />
maybe g h mx<br />
</haskell><br />
<br />
== head, tail ==<br />
<br />
You should replace<br />
<haskell><br />
if null xs<br />
then g<br />
else h (head xs) (tail xs)<br />
</haskell><br />
by<br />
<haskell><br />
case xs of<br />
[] -> g<br />
y:ys -> h y ys<br />
</haskell><br />
<br />
== init, last ==<br />
<br />
You may replace<br />
<haskell><br />
if null xs<br />
then g<br />
else h (init xs) (last xs)<br />
</haskell><br />
by<br />
<haskell><br />
case xs of<br />
[] -> g<br />
y:ys -> uncurry h $ viewRTotal y ys<br />
<br />
viewRTotal :: a -> [a] -> ([a], a)<br />
viewRTotal x xs =<br />
forcePair $<br />
foldr<br />
(\x0 go y -> case go y of ~(zs,z) -> (x0:zs,z))<br />
(\y -> ([],y))<br />
xs x<br />
<br />
forcePair :: (a,b) -> (a,b)<br />
forcePair ~(a,b) = (a,b)<br />
</haskell><br />
<br />
Alternatively, you may import from {{HackagePackage|id=utility-ht}}:<br />
* [http://hackage.haskell.org/packages/archive/utility-ht/0.0.8/doc/html/Data-Tuple-HT.html forcePair]<br />
* [http://hackage.haskell.org/packages/archive/utility-ht/0.0.8/doc/html/Data-List-HT.html viewR]<br />
* [http://hackage.haskell.org/packages/archive/utility-ht/0.0.8/doc/html/Data-List-HT.html switchR].<br />
<br />
== (!!) ==<br />
<br />
You should replace<br />
<haskell><br />
if k < length xs<br />
then xs!!k<br />
else y<br />
</haskell><br />
by<br />
<haskell><br />
case drop k xs of<br />
x:_ -> x<br />
[] -> y<br />
</haskell><br />
<br />
This is also more lazy, since for computation of <hask>length</hask> you have to visit every element of the list.<br />
<br />
<br />
== irrefutable pattern match on (:) ==<br />
<br />
You should replace<br />
<haskell><br />
if k < length xs<br />
then let (prefix,x:suffix) = splitAt k xs<br />
in g prefix x suffix<br />
else y<br />
</haskell><br />
by<br />
<haskell><br />
case splitAt k xs of<br />
(prefix,x:suffix) -> g prefix x suffix<br />
(_,[]) -> y<br />
</haskell><br />
<br />
<br />
== minimum ==<br />
<br />
The function <hask>isLowerLimit</hask> checks if a number is a lower limit to a sequence.<br />
You may implement it with the partial function <hask>minimum</hask>.<br />
<haskell><br />
isLowerLimit :: Ord a => a -> [a] -> Bool<br />
isLowerLimit x ys = x <= minimum ys<br />
</haskell><br />
It fails if <hask>ys</hask> is empty or infinite.<br />
<br />
You should replace it by<br />
<haskell><br />
isLowerLimit x = all (x<=)<br />
</haskell><br />
This definition terminates for infinite lists, if <hask>x</hask> is not a lower limit. It aborts immediately if an element is found which is below <hask>x</hask>.<br />
Thus it is also faster for finite lists.<br />
Even more: It also works for empty lists.<br />
<br />
<br />
[[Category:Tutorials]]<br />
[[Category:Style]]<br />
[[Category:Idioms]]</div>Bjornhttps://wiki.haskell.org/index.php?title=Physical_units&diff=59850Physical units2015-06-10T09:20:34Z<p>Bjorn: dimensional project has moved to Github</p>
<hr />
<div>How would one go about modeling units (seconds, meters, meters per second, etc) in Haskell? I'm particularly interested in getting the typechecker to verify proper usage, and do not want to restrict it to any particular numeric representation (i.e. both integral seconds and fractional seconds). If this can in fact be done, it could also be used to model coordinate system axes in, say, Geometric Algebra.<br />
<br />
* It can. Look at [[Dimensionalized numbers]] for a toy implementation. I've thought a bit about the Geometric Algebra case, but I can't see a good way of handling it without forcing a choice of basis. I'm also not sure how it would work -- the whole point of GA is to incorporate areas, lengths, volumes, etc. into one number type. I suppose we could use this type of technique to segregate GA spaces with different dimensions or even metrics. --AaronDenney<br />
<br />
* A (non-toy) implementation of statically checked physical dimensions with a complete set of dimensions (but limited number of predefined units) is [https://github.com/bjornbm/dimensional Dimensional]. I apologize for coming up with the same name as Aaron and am on the lookout for a new one. I cannot comment on the applicability to GA. --[[User:Bjorn|Bjorn]]<br />
<br />
* NumericPrelude also contains an implementation of values equipped with physical units. However all unit checking is made dynamically, that is expressions like <hask>1 * meter < 2 * second</hask> are accepted by the Haskell compiler but lead to a runtime error. This design allows the programmer to process values from IO world with units, that are unknown at compile time, but it prohibits catching unit errors at compile time. Units are handled as integer vectors of exponents of base units. Computation with these vectors is rather simple, however formatting them is difficult. Formatting and parsing values with units is supported. A small library of SI units is provided.<br />
: http://code.haskell.org/numeric-prelude/src/Number/Physical.hs<br />
: http://code.haskell.org/numeric-prelude/src/Number/SI.hs<br />
<br />
:Get with <code>darcs get http://code.haskell.org/numeric-prelude/</code><br />
<br />
* The {{HackagePackage|id=quantities}} package uses an expression parser to create units. For example: <br />
:<code>>>> fromString "(1m + 1ft + 2 yard + 50in) * 5 / (8 km/h) => minute"<br />
:Right 0.16513500000000006 minute</code><br />
<br />
:Of course, this is not verified with the type checker. It uses a custom error type to report issues like undefined units or improper conversions.<br />
<br />
* poor man's type level [http://code.haskell.org/numeric-prelude/src/Number/DimensionTerm.hs physical dimensions] in [[Numeric Prelude]]<br />
<br />
* See also the [http://www.cis.upenn.edu/~eir/packages/units/ units] package, which uses type families to implement a domain-specific type system for dimension-checked programming. It works only with GHC 7.8+.<br />
<br />
* [[CalDims]]<br />
<br />
* {{HackagePackage|id=unittyped}}<br />
<br />
* {{HackagePackage|id=Measure}} - Encompasses a few units, currently has build failure on ghc >= 7.0.<br />
<br />
* {{HackagePackage|id=time-units}} - for time units only.<br />
<br />
* [https://github.com/aavogt/DimMat DimMat] - statically typed units for some operations provided by {{HackagePackage|id=hmatrix}}, where the scalars have the same types as {{HackagePackage|id=dimensional-tf}}<br />
<br />
[[Category:Mathematics]]</div>Bjornhttps://wiki.haskell.org/index.php?title=Applications_and_libraries/Mathematics&diff=59849Applications and libraries/Mathematics2015-06-10T09:18:53Z<p>Bjorn: /* Physical units */ dimensional project has moved to Github</p>
<hr />
<div>== Applications ==<br />
<br />
=== Physics ===<br />
<br />
;[http://ab-initio.mit.edu/meep/ Meep]<br />
:Meep (or MEEP) is a free finite-difference time-domain (FDTD) simulation software package developed at MIT to model electromagnetic systems. Meep used Haskell to generate C++ code, after Meep [http://ab-initio.mit.edu/wiki/index.php/Meep_release_notes 1.0] Haskell generation droped in favor of handwritten C++ code. <br />
<br />
;[[Numeric Quest]]<br />
:Jan Skibinski's [[Numeric Quest]] library provides modules that are useful for Quantum Mechanics, among other things.<br />
<br />
== Libraries ==<br />
<br />
=== Linear algebra ===<br />
<br />
;[http://hackage.haskell.org/package/bed-and-breakfast bed-and-breakfast]<br />
:A library that implements Matrix operations in pure Haskell using mutable arrays and the ST Monad. bed-and-breakfast does not need any additional software to be installed and can perform basic matrix operations like multiplication, finding the inverse, and calculating determinants efficiently.<br />
<br />
;[https://github.com/patperry/hs-linear-algebra hs-linear-algebra]<br />
:Patrick Perry's linear algebra library, built on BLAS. [https://github.com/cartazio/hs-cblas hs-cblas] seems to be a more up-to-date fork.<br />
<br />
;[http://www.cs.utah.edu/~hal/HBlas/index.html Wrapper to CLAPACK]<br />
<br />
;[http://haskelldsp.sourceforge.net/ Digital Signal Processing]<br />
:Modules for matrix manipulation, Fourier transform, interpolation, spectral estimation, and frequency estimation.<br />
<br />
;[http://article.gmane.org/gmane.comp.lang.haskell.general/13561 Index-aware linear algebra]<br />
:Frederik Eaton's library for statically checked matrix manipulation in Haskell<br />
<br />
;[[Numeric Quest]]<br />
:Jan Skibinski's [[Numeric Quest]] library provides several modules that are useful for linear algebra in general, among other things.<br />
<br />
;[[vector-space]]<br />
:The [[vector-space]] package defines classes and generic operations for vector spaces and affine spaces. It also defines a type of infinite towers of generalized derivatives (linear transformations).<br />
<br />
;[http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hmatrix HMatrix]<br />
:By Alberto Ruiz. From the project [http://perception.inf.um.es/hmatrix/ website]:<br />
::''A purely functional interface to linear algebra and other numerical algorithms, internally implemented using LAPACK, BLAS, and GSL.<br />
<br />
::''This package includes standard matrix decompositions (eigensystems, singular values, Cholesky, QR, etc.), linear systems, numeric integration, root finding, etc.<br />
<br />
;[http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Vec Vec]<br />
:By Scott E. Dillard. Static dimension checking:<br />
::''Vectors are represented by lists with type-encoded lengths. The constructor is :., which acts like a cons both at the value and type levels, with () taking the place of nil. So x:.y:.z:.() is a 3d vector. The library provides a set of common list-like functions (map, fold, etc) for working with vectors. Built up from these functions are a small but useful set of linear algebra operations: matrix multiplication, determinants, solving linear systems, inverting matrices.''<br />
<br />
== See also ==<br />
<br />
* [[Linear algebra]]<br />
* [[Mathematical prelude discussion]]<br />
<br />
<br />
See also: [[Linear algebra|Design discussions]]<br />
<br />
=== [[Physical units]] ===<br />
<br />
;[[Dimensionalized numbers]]<br />
: Working with physical units like second, meter and so on in a type-safe manner.<br />
<br />
;[http://darcs.haskell.org/numericprelude/src/Number/SI.hs NumericPrelude: Physical units]<br />
: Numeric values with dynamically checked units.<br />
<br />
;[[CalDims]]<br />
:This is not simply a library providing a new type of <hask>Num</hask> class, but stand-alone calculation tool that supports user defined functions and units (basic and derived), so it can provide dimension-safe calculation (not embedded but via shell). Calculations can be modified/saved via shell. It uses rational numbers to avoid rounding errors where possible.<br />
<br />
;[https://github.com/bjornbm/dimensional Dimensional]<br />
: Library providing data types for performing arithmetic with physical quantities and units. Information about the physical dimensions of the quantities/units is embedded in their types and the validity of operations is verified by the type checker at compile time. The boxing and unboxing of numerical values as quantities is done by multiplication and division of units.<br />
<br />
=== Number representations ===<br />
<br />
==== Decimal numbers ====<br />
<br />
;[http://src.seereason.com/decimal/ Decimal arithmetic library]<br />
:An implementation of real decimal arithmetic, for cases where the binary floating point is not acceptable (for example, money).<br />
<br />
==== Real and rational numbers ====<br />
<br />
There are several levels of [[Exact real arithmetic|handling real numbers]] and according libraries.<br />
<br />
===== Arbitrary precision =====<br />
<br />
* Numbers have fixed precision<br />
* Rounding errors accumulate<br />
* Sharing is easy, i.e. in <hask>sqrt pi + sin pi</hask>, <hask>pi</hask> is computed only once<br />
* Fast, because the routines can make use of the fast implementation of <hask>Integer</hask> operations<br />
<br />
;[[Numeric Quest]]<br />
:Jan Skibinski's [[Numeric Quest]] library provides, among other things, a type for arbitrary precision rational numbers with transcendental functions.<br />
<br />
;[http://cvs.haskell.org/darcs/numericprelude/src/Number/FixedPoint.hs FixedPoint.hs]<br />
:part of NumericPrelude project<br />
<br />
;[http://hackage.haskell.org/cgi-bin/hackage-scripts/package/AERN-Basics AERN-Basics] [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/AERN-Real AERN-Real] [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/AERN-Real-Interval AERN-Real-Interval] [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/AERN-Real-Double AERN-Real-Double]<br />
:contains type classes that form a foundation for ''rounded arithmetic'' and ''interval arithmetic'' with explicit control of rounding and the possibility to increase the rounding precision arbitrarily for types that support it. At the moment there are instances for Double floating point numbers where one can control the direction of rounding but cannot increase the rounding precision. In the near future instances for MPFR arbitrary precision numbers will be provided. Intervals can use as endpoints any type that supports directed rounding in the numerical order (such as Double or MPFR) and operations on intervals are rounded either outwards or inwards. Outwards rounding allows to safely approximate exact real arithmetic while a combination of both outwards and inwards rounding allows one to safely approximate exact interval arithmetic. Inverted intervals with Kaucher arithmetic are also supported.<br />
<br />
;[http://hackage.haskell.org/cgi-bin/hackage-scripts/package/AERN-RnToRm AERN-RnToRm]<br />
:contains arithmetic of ''piecewise polynomial function intervals'' that approximate multi-dimensional (almost everywhere) continuous real functions to arbitrary precision<br />
<br />
;[http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hmpfr hmpfr]<br />
:hmpfr is a purely functional haskell interface to the [http://www.mpfr.org/ MPFR] library<br />
<br />
;[http://hackage.haskell.org/package/numbers numbers]<br />
:provides an up-to-date, easy-to-use BigFloat implementation that builds with a modern GHC, among other things.<br />
<br />
===== Dynamic precision =====<br />
<br />
* You tell the precision and an expression shall be computed to, and the computer finds out, how precisely to compute the input values<br />
* Rounding errors do not accumulate<br />
* Sharing of temporary results is difficult, that is, in <hask>sqrt pi + sin pi</hask>, <hask>pi</hask> ''will'' be computed twice, each time with the required precision.<br />
* Almost as fast as arbitrary precision computation<br />
<br />
;[http://www.cs.man.ac.uk/arch/dlester/exact.html ERA] is an implementation (in Haskell 1.2) by David Lester.<br />
: It is quite fast, possibly the fastest Haskell implementation. At 220 lines it is also the shortest. Probably the shortest implementation of exact real arithmetic in any language.<br />
: The provided number type <hask>CReal</hask> is instance of the Haskell 98 numeric type classes and thus can be used whereever you used Float or Double before and encountered some numerical difficulties.<br />
:Here is a mirror: http://darcs.augustsson.net/Darcs/CReal/<br />
<br />
;[http://www.doc.ic.ac.uk/~ae/exact-computation/#bm:implementations IC-Reals] is an implementation by Abbas Edalat, Marko Krznar&#263; and Peter J. Potts.<br />
:This implementation uses linear fractional transformations.<br />
<br />
;[http://r6.ca/ Few Digits] by Russell O'Connor.<br />
:This is a prototype of the implementation he intendeds to write in [http://coq.inria.fr/ Coq]. Once the Coq implementation is complete, the Haskell code could be extracted producing an implementation that would be proved correct.<br />
<!--<br />
Example:<br />
*Data.Real.CReal> answer 1000 (exp 1 + sqrt 2)<br />
--><br />
<br />
;COMP is an implementation by Yann Kieffer.<br />
:The work is in beta and relies on new primitive operations on Integers which will be implemented in GHC. The library isn't available yet.<br />
<br />
;[http://www2.arnes.si/~abizja4/hera/ Hera] is an implementation by Aleš Bizjak.<br />
:It uses the [http://www.mpfr.org/ MPFR] library to implement dyadic rationals, on top of which are implemented intervals and real numbers. A real number is represented as a function <hask>Int -> Interval</hask> which represents a sequence of intervals converging to the real.<br />
<br />
===== Dynamic precision by lazy evaluation =====<br />
<br />
The real numbers are represented by an infinite datastructure, which allows you to increase precision successively by evaluating the data structure successively. All of the implementations below use some kind of digit stream as number representation.<br />
Sharing of results is simple.<br />
The implementations are either fast on simple expressions, because they use large blocks/bases, or they are fast on complex expressions, because they consume as little as possible input digits in order to emit the required output digits.<br />
<br />
;[http://medialab.freaknet.org/bignum/ BigFloat] is an implementation by Martin Guy.<br />
:It works with streams of decimal digits (strictly in the range from 0 to 9) and a separate sign. The produced digits are always correct. Output is postponed until the code is certain what the next digit is. This sometimes means that [http://medialab.freaknet.org/bignum/dudeney.html no more data is output].<br />
<br />
;In [http://users.info.unicaen.fr/~karczma/arpap/lazypi.ps.gz "The Most Unreliable Technique in the World to compute pi"] Jerzy Karczmarczuk develops some functions for computing pi lazily.<br />
<br />
;[http://darcs.haskell.org/numericprelude/src/Number/Positional.hs NumericPrelude: positional numbers]<br />
:Represents a real number as pair <hask>(exponent,[digit])</hask>, where the digits are <hask>Int</hask>s in the open range <hask>(-basis,basis)</hask>. There is no need for an extra sign item in the number data structure. The <hask>basis</hask> can range from <hask>10</hask> to <hask>1000</hask>. (Binary representations can be derived from the hexadecimal representation.) Showing the numbers in traditional format (non-negative digits) fails for fractions ending with a run of zeros. However the internal representation with negative digits can always be shown and is probably more useful for further processing. An interface for the numeric type hierarchy of the NumericPrelude project is provided.<br />
:It features<br />
:* basis conversion<br />
:* basic arithmetic: addition, subtraction, multiplication, division<br />
:* algebraic arithmetic: square root, other roots (no general polynomial roots)<br />
:* transcendental arithmetic: pi, exponential, logarithm, trigonometric and inverse trigonometric functions<br />
<br />
=== Type class hierarchies ===<br />
<br />
There are several approaches to improve the [[Mathematical prelude discussion|numeric type class hierarchy]].<br />
<br />
;Dylan Thurston and Henning Thielemann's [[Numeric Prelude]]<br />
:Experimental revised framework for numeric type classes. Needs hiding of Prelude, overriding hidden functions like fromInteger and multi-parameter type classes. Probably restricted to GHC.<br />
<br />
;Jerzy Karczmarczuk's [http://www.haskell.org/pipermail/haskell-cafe/2001-February/001510.html approach]<br />
<br />
;Serge D. Mechveliani's [ftp://ftp.botik.ru/pub/local/Mechveliani/basAlgPropos/ Basic Algebra proposal]<br />
<br />
;Andrew Frank's [http://www.haskell.org/pipermail/haskell-cafe/2006-April/015326.html approach]<br />
:The proposal: ftp://ftp.geoinfo.tuwien.ac.at/frank/numbersPrelude_v1.pdf<br />
<br />
;Haskell Prime: [http://hackage.haskell.org/trac/haskell-prime/ticket/112 Ongoing efforts for the language revision]<br />
<br />
=== Discrete mathematics ===<br />
<br />
;[http://andrew.bromage.org/darcs/numbertheory/ Number Theory Library]<br />
:Andrew Bromage's Haskell number theory library, providing operations on primes, fibonacci sequences and combinatorics.<br />
<br />
;[http://users.skynet.be/jyp/HGAL/ HGAL]<br />
:An haskell implementation of Brendan McKay's algorithm for graph canonic labeling and automorphism group. (aka Nauty)<br />
<br />
;[http://www.cambridge.org/uk/catalogue/catalogue.asp?isbn=0521849306 Computational Oriented Matroids]<br />
:is a book by [http://wwwopt.mathematik.tu-darmstadt.de/~bokowski/ Jürgen G. Bokowski], where he develops Haskell code for Matroid computations.<br />
<br />
See also [[Libraries and tools/Cryptography]]<br />
<br />
=== Computer Algebra ===<br />
<br />
<!-- Older link: http://haskell.org/docon/ --><br />
; [http://homepages.inf.ed.ac.uk/wadler/realworld/docon2.html DoCon], the Algebraic Domain Constructor<br />
: A library by Sergey D. Mechveliani for Algebra, turns GHCi into a kind of Computer Algebra System<br />
<br />
;[http://www.info.unicaen.fr/~karczma/arpap/ Papers by Jerzy Karczmarczuk]<br />
:Some interesting uses of Haskell in mathematics, including [[functional differentiation]], power series, continued fractions.<br />
<br />
;[http://www.robtougher.com/HCAS/ HCAS] by Rob Tougher.<br />
<br />
=== Statistics ===<br />
;[http://hackage.haskell.org/package/hstats hstats]<br />
: Statistical Computing with Haskell<br />
<br />
;[http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hmatrix-gsl-stats hmatrix-gsl-stats]<br />
: A binding to the statistics portion of GSL. Works with hmatrix<br />
<br />
;[http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hstatistics hstatistics]<br />
: A library for doing statistics. Works with hmatrix<br />
<br />
=== Plotting ===<br />
<br />
;[http://hackage.haskell.org/package/easyplot easyplot]<br />
: Simple and easy wrapper to gnuplot.<br />
<br />
;[[Gnuplot]]<br />
: Simple wrapper to gnuplot<br />
<br />
;[http://hackage.haskell.org/packages/archive/hmatrix/latest/doc/html/Graphics-Plot.html hmatrix]<br />
: contains a deprecated gnuplot wrapper<br />
<br />
;[http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Chart Chart]<br />
: A library for generating 2D Charts and Plots, based upon the cairo graphics library.<br />
<br />
;[http://hackage.haskell.org/cgi-bin/hackage-scripts/package/plot plot]<br />
: A library for generating figures, based upon the cairo graphics libary with<br />
a simple, monadic interface.<br />
<br />
;[http://hackage.haskell.org/cgi-bin/hackage-scripts/package/probability probability]<br />
: the module Numeric.Probability.Visualize contains a wrapper to [http://www.r-project.org/ R]<br />
<br />
=== Numerical optimization ===<br />
This classification is somewhat arbitrary. Something more systematic like GAMS might be helpful.<br />
<br />
==== bindings ====<br />
;[http://repetae.net/john/recent/out/HsASA.html Adaptive Simulated Annealing]<br />
:A Haskell interface to Lester Ingber's adaptive simulating annealing code.<br />
<br />
;[http://hackage.haskell.org/package/cmaes CMA-ES]<br />
:A wrapper for Covariance Matrix Adaptation Evolution Strategy<br />
<br />
;[https://github.com/ghorn/nlopt-haskell nlopt-haskell]<br />
:A low-level binding to the nlopt library<br />
<br />
;[http://hackage.haskell.org/package/ipopt-hs ipopt-hs]<br />
:A haskell binding to ipopt including automatic differentiation<br />
<br />
;[http://hackage.haskell.org/package/glpk-hs glpk-hs]<br />
:A high-level interface to GLPK's linear programming and mixed integer programming features.<br />
<br />
==== pure haskell ====<br />
;[http://hackage.haskell.org/package/nonlinear-optimization nonlinear-optimization]<br />
:A pure-haskell CG_DESCENT method is implemented<br />
<br />
=== Miscellaneous libraries ===<br />
<br />
;[http://www.robtougher.com/HaskellMath/ HaskellMath]<br />
:The HaskellMath library is a sandbox for experimenting with mathematics algorithms. So far I've implemented a few quantitative finance models (Black Scholes, Binomial Trees, etc) and basic linear algebra functions. Next I might work on either computer algebra or linear programming. All comments welcome!<br />
<br />
;[http://hackage.haskell.org/package/HaskellForMaths HaskellForMaths]<br />
:David Amos' library for combinatorics, group theory, commutative algebra and non-commutative algebra, which is described in an [http://haskellformaths.blogspot.com/ accompanying blog].<br />
<br />
;[http://darcs.haskell.org/htam/ Various math stuff by Henning Thielemann]<br />
:This is some unsorted mathematical stuff including: gnuplot wrapper (now maintained as separate package), portable grey map (PGM) image reader and writer, simplest numerical integration, differentiation, zero finding, interpolation, solution of differential equations, combinatorics, some solutions of math riddles, computation of fractal dimensions of iterated function systems (IFS)<br />
<br />
;[[Numeric Quest]]<br />
:Jan Skibinski wrote a collection of Haskell modules that are useful for Mathematics in general, and Quantum Mechanics in particular.<br />
<br />
:Some of the modules are hosted on [http://darcs.haskell.org/numeric-quest/ haskell.org]. They include modules for:<br />
:* Rational numbers with transcendental functions<br />
:* Roots of polynomials<br />
:* Eigensystems<br />
:* Tensors<br />
:* Dirac quantum mechanics<br />
<br />
:Other modules in Numeric Quest are currently only available via the [http://web.archive.org/web/20010605003250/http://www.numeric-quest.com/haskell/ Internet Archive]. They include, among many other things:<br />
:* [http://web.archive.org/web/*/http://www.numeric-quest.com/haskell/ State vector evolution]<br />
:* [http://web.archive.org/web/*/http://www.numeric-quest.com/haskell/ Short study of fuzzy oscillator]<br />
<br />
:See the [[Numeric Quest]] page for more information.<br />
<br />
;[http://www.dinkla.net/fp/cglib.html Geometric Algorithms]<br />
:A small Haskell library, containing algorithms for two-dimensional convex hulls, triangulations of polygons, Voronoi-diagrams and Delaunay-triangulations, the QEDS data structure, kd-trees and range-trees.<br />
<br />
;[http://home.solcon.nl/mklooster/repos/hmm/ Hmm: Haskell Metamath]<br />
:Hmm is a small Haskell library to parse and verify Metamath databases.<br />
<br />
;[[Probabilistic Functional Programming]]<br />
:The PFP library is a collection of modules for Haskell that facilitates probabilistic functional programming, that is, programming with stochastic values. The probabilistic functional programming approach is based on a data type for representing distributions. A distribution represent the outcome of a probabilistic event as a collection of all possible values, tagged with their likelihood. A nice aspect of this system is that simulations can be specified independently from their method of execution. That is, we can either fully simulate or randomize any simulation without altering the code which defines it.<br />
<br />
;[[Sinc function]]<br />
<br />
;[[Gamma and Beta function]]<br />
<br />
;[http://repetae.net/john/recent/out/Boolean.html Boolean]<br />
:A general boolean algebra class and some instances for Haskell.<br />
<br />
;[http://darcs.haskell.org/~lemmih/hode/ HODE]<br />
:HODE is a binding to the Open Dynamics Engine. ODE is an open source, high performance library for simulating rigid body dynamics.<br />
<br />
;[http://sourceforge.net/projects/ranged-sets Ranged Sets]<br />
:A ranged set is a list of non-overlapping ranges. The ranges have upper and lower boundaries, and a boundary divides the base type into values above and below. No value can ever sit on a boundary. So you can have the set <math>(2.0, 3.0] \cup (5.3, 6)</math>.<br />
<br />
;[http://code.google.com/p/hhydra/ hhydra]<br />
:Hhydra is a tool to compute Goodstein successions and hydra puzzles described by Bernard Hodgson in his article 'Herculean or Sisyphean tasks?' published in No 51 March 2004 of the Newsletter of the European Mathematical Society.<br />
<br />
[[Category:Mathematics|*]]<br />
{{LibrariesPage}}</div>Bjornhttps://wiki.haskell.org/index.php?title=Reactive-banana/Examples&diff=43986Reactive-banana/Examples2012-01-15T14:40:59Z<p>Bjorn: /* Core Examples */ “run” was renamed to “actuate” in the repo.</p>
<hr />
<div>Examples for the reactive-banana library.<br />
<br />
== Core Examples ==<br />
<br />
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana/doc/examples/SlotMachine.hs SlotMachine.hs]<br />
: Mainly demonstrates how to set up an event network with your own event loop. Also demonstrates the FRP functionality.<br />
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana/doc/examples/ActuatePause.hs ActuatePause.hs]<br />
: Demonstrates how to set up an event network with your own event loop and how to pause or resume it.<br />
<br />
== GUI Examples - Very simple ==<br />
<br />
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/Arithmetic.hs Arithmetic.hs]<br />
: Minimalistic calculator that can add two numbers. Demonstrates how to read values from text entries and respond to button clicks.<br />
[[Image:Reactive-banana-Arithmetic.png]]<br />
<br />
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/Counter.hs Counter.hs]<br />
: A simple counter that can be manipulated with two buttons "Up" or "Down". Demonstrates the <code>accumD</code> function.<br />
[[Image:Reactive-banana-Counter.png]]<br />
<br />
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/NetMonitor.hs NetMonitor.hs]<br />
: Minimalistic application that displays network statistics in real time. Demonstrates the <code>fromPoll</code> function.<br />
[[Image:Reactive-banana-NetMonitor.png]]<br />
<br />
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/CurrencyConverter.hs CurrencyConverter.hs]<br />
: Simple currency converter. Reads and writes values to text entry widgets in real-time. Demonstrates how to use value recursion in the <code>NetworkDescription</code> monad.<br />
[[Image:Reactive-banana-CurrencyConverter.png]]<br />
<br />
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/TwoCounters.hs TwoCounters.hs]<br />
: Two simple counters. There is only one pair of buttons "Up" or "Down", the button "Switch Counters" allows you to specify which counter should be affected. [[Image:Reactive-banana-TwoCounters.png]]<br />
<br />
== GUI Examples - More elaborate ==<br />
<br />
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/Asteroids.hs Asteroids.hs]<br />
: Port of the [[wxAsteroids]] example.<br />
[[Image:Reactive-banana-wxAsteroids.png]]<br />
<br />
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/CRUD.hs CRUD.hs]<br />
: A toy CRUD (Create/Read/Update/Destroy) application. Demonstrates how to do incremental updates. Of course, this makes the code quite messy, but I think it's still pretty nice. For instance, it was quite easy to add the filter box.<br />
[[Image:Reactive-banana-CRUD1.png]] [[Image:Reactive-banana-CRUD2.png]]<br />
<br />
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/TicTacToe.hs TicTacToe.hs]<br />
: A version of TicTacToe with eclectic interface elements, courtesy of Gideon Sireling.<br />
[[Image:Reactive-banana-TicTacToe.png]]<br />
<br />
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/Wave.hs Wave.hs]<br />
: A wave-like pattern. Not the most beautiful code, but it demonstrates that you can generated timed events.<br />
[[Image:Reactive-banana-Wave.png]]</div>Bjornhttps://wiki.haskell.org/index.php?title=User:Bjorn&diff=39406User:Bjorn2011-04-08T15:06:15Z<p>Bjorn: New page: Björn Buckwalter lives in Sweden and hacks on the [http://dimensional.googlecode.com dimensional] library. Most of his code lives on [https://github.com/bjornbm GitHub].</p>
<hr />
<div>Björn Buckwalter lives in Sweden and hacks on the [http://dimensional.googlecode.com dimensional] library. Most of his code lives on [https://github.com/bjornbm GitHub].</div>Bjornhttps://wiki.haskell.org/index.php?title=Talk:Package_versioning_policy&diff=39405Talk:Package versioning policy2011-04-08T15:01:16Z<p>Bjorn: Fixity changes and PVP?</p>
<hr />
<div>How about describing the semantics of versions in the following way?<br />
<br />
1. If none of the module interfaces of your package have changed, the A.B.C prefix can remain the same.<br />
<br />
2. If a user of the package only used qualified imports and/or imports a specified list of functions would imply that they could use your new package version, then the A.B prefix can remain the same.<br />
<br />
3. Otherwise, the A.B prefix must be incremented.<br />
<br />
Is this equivalent to the versioning policy?<br />
<br />
--[[User:Roconnor|Roconnor]] 20:28, 29 August 2009 (UTC)<br />
<br />
A special case that is not discussed is change of fixity. I presume fixity changes should require bumping the major version?<br />
<br />
--[[User:Bjorn|Bjorn]] 15:01, 8 April 2011 (UTC)</div>Bjornhttps://wiki.haskell.org/index.php?title=Hac_%CF%86_2009&diff=28265Hac φ 20092009-05-22T00:55:44Z<p>Bjorn: </p>
<hr />
<div>== About ==<br />
<br />
Hac φ, to be held at the University of Pennsylvania in Philadelphia, is in the early planning stages. It will be an informal Haskell hackathon/get-together for the eastern US (although people are welcome to come from elsewhere too!). At this point we are just trying to gauge interest and pick a date; watch this space for more details as they are decided.<br />
<br />
At this point the possible dates are<br />
<br />
'''June 19-21, 2009'''<br />
<br />
or<br />
<br />
'''July 24-26, 2009'''<br />
<br />
If you think you might like to attend (no committment necessary), please add your name below. Also, please make a note if either of the above dates absolutely does not work for you.<br />
<br />
== Attendees ==<br />
<br />
* Daniel Wagner (organizer)<br />
* Brent Yorgey (organizer)<br />
* Andrew Wagner (chessguy) - I think I can make either day work, but I'll already be in Philly with nothing to do on the July weekend<br />
* Jake McArthur (jmcarthur/geezusfreeek)<br />
* Bjorn Buckwalter - July should work for me. June wouldn't.<br />
<br />
[[Category:Community]]<br />
[[Category:Events]]<br />
[[Category:Hackathon]]</div>Bjornhttps://wiki.haskell.org/index.php?title=Wanted_libraries&diff=20908Wanted libraries2008-05-10T04:11:01Z<p>Bjorn: OpenID consumer library</p>
<hr />
<div>[[Category:Libraries]]<br />
This page provides a list of missing and found libraries for solving<br />
common ''real world'' programmer tasks.<br />
<br />
If you think there should be a library for some common task, add it to<br />
this page, and someone may well step up and write it. If you know of a<br />
library to solve an open problem domain, link to it.<br />
<br />
The first place to look is [[Libraries_and_tools|the full libraries list]].<br />
<br />
<br />
== Missing libraries (by problem domain) ==<br />
<br />
=== IMAP ===<br />
A functional IMAP library would be nice, particularly one that can be used in conjunction with encryption and authentication. References have been found to a SoC project although it appears to be derelict. <br />
<br />
=== Numerical algorithms ===<br />
Stuff to compute bessel functions, struve H1 etc.<br />
<br />
=== .NET/Java Interoperability ===<br />
We could use a .NET FFI library that lets you easily call into the .NET framework. Perhaps the (abandoned?) [http://galois.com/~sof/hugs98.net/ Hugs .NET FFI library] could be resurrected/updated and ported to GHC? Maybe a tool could even be created that automates the interoperability of Haskell and arbitrary .NET libraries?<br />
<br />
: I'm working on a Haskell to .NET bridge for my undergraduate thesis. The goal is to provide access to arbitrary .NET libraries from Haskell, with a convenient syntax. I expect to have something releasable in a few weeks. [[User:AndrewA|AndrewA]] 13:33, 6 October 2007 (UTC)<br />
<br />
=== AMQP Client ===<br />
It will be great to have a client for the open source protocol AMQ (http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol). This is a new transport protocol, solving problems currently addressed by Java Messaging Service, MQ, Tibco RV, etc. Financial companies such infrastructure to distribute massive amounts of market data (although the protocol can be used for effeciently distributing anything)<br />
<br />
=== STOMP Client ===<br />
The Streaming Text Orientated Messaging Protocol (http://stomp.codehaus.org/) is a messaging protocol supported by a good number of languages and message brokers. While not high-performance like AMQP it is apparently near trivial to implement and interact with.<br />
<br />
=== Darcs Bindings ===<br />
Many darcs users have requested an interface to darcs as a C library. Creating this library would involve deciding on the details of the API and generating the bindings using the Haskell FFI. Designing the API is mostly done for you by following the structure of the darcs source code and how the existing commands interface with the core of darcs.<br />
<br />
=== OpenID Relying Party (Consumer) library ===<br />
A library allowing (web) applications to authenticate users with an OpenID would be great. WikiPedia has a good [http://en.wikipedia.org/wiki/OpenID#Logging_in description] of what is expected from the relying party.<br />
<br />
== Could be improved ==<br />
<br />
Problems with existing solutions, that could be improved.<br />
<br />
* The core HTTP libraries need a lot of work. There is the beginnings of a useful library there, but many http codes are not handled, and there should be simple 'get' and 'head' functionality. <br />
* Binary serialisation support should be ported to bytestring, and added to the extralibs bundle<br />
* Support for wider Word values in bytestring.<br />
* Adding bytestring support to Parsec.<br />
* Simple process forking/popen, of type <hask>String -> IO String</hask>, is needed (the implementation should be in base)<br />
<br />
If you have code that improves on something in the base libraries, you might consider [[Library_submissions|submitting it to the libraries process]], so it can appear in the standard libraries.<br />
<br />
== Existing libraries (by problem domain) ==<br />
<br />
See [[Libraries_and_tools|the full libraries list]].<br />
<br />
=== GUIs ===<br />
<br />
See [[Libraries_and_tools/GUI_libraries|GUI libraries]]<br />
<br />
=== High performance string IO ===<br />
<br />
See [[Libraries_and_tools/Data_structures#Strings|String libraries]]<br />
<br />
=== Binary IO ===<br />
<br />
See [[Libraries_and_tools/Data_structures#Serialising_data|Binary IO]]<br />
<br />
=== Compression ===<br />
<br />
See [[Libraries_and_tools/Data_structures#Compressing_data|Compressing data]]<br />
<br />
=== Encryption ===<br />
<br />
See [[Libraries_and_tools/Cryptography|Crypto libraries]]<br />
<br />
=== Web frameworks ===<br />
<br />
See [[Libraries_and_tools/Web_programming#Web_frameworks|Web frameworks]]<br />
<br />
=== XML processing ===<br />
<br />
See [[Libraries_and_tools/Web_programming#XML|XML handling]]<br />
<br />
=== Database access ===<br />
<br />
See [[Libraries_and_tools/Database_interfaces|Databases]]<br />
<br />
== Libraries to package ==<br />
<br />
Several cool libraries are out there, not yet in hackage / cabal format.<br />
Some on the hitlist , that would be great to package up would be:<br />
<br />
* [http://www.eyrie.org/~zednenem/2004/hsce/Control.Comonad.html Control.Comonad]<br />
* [http://okmij.org/ftp/Computation/monads.html#LogicT LogicT]<br />
* [http://okmij.org/ftp/Computation/monads.html#random-var-monad probabilistic monads]<br />
* one of the libcurl bindings, either http://code.haskell.org/curl/ or better yet the SoC work at http://google-summer-of-code-2007-haskell.googlecode.com/files/Mieczyslaw_Bak.tar.gz.<br />
<br />
== C libraries ==<br />
<br />
C libraries are often very popular, and cheap to bind to. A good task<br />
would be to just write bindings to C libraries, sorted by popularity.<br />
<br />
Possible library rankings are provided by:<br />
<br />
* Debian packages ranked by:<br />
** [http://popcon.debian.org/source/by_inst Installations]<br />
** [http://popcon.debian.org/source/by_vote Votes]</div>Bjornhttps://wiki.haskell.org/index.php?title=Wanted_libraries&diff=20907Wanted libraries2008-05-10T03:58:17Z<p>Bjorn: Added STOMP client to library list.</p>
<hr />
<div>[[Category:Libraries]]<br />
This page provides a list of missing and found libraries for solving<br />
common ''real world'' programmer tasks.<br />
<br />
If you think there should be a library for some common task, add it to<br />
this page, and someone may well step up and write it. If you know of a<br />
library to solve an open problem domain, link to it.<br />
<br />
The first place to look is [[Libraries_and_tools|the full libraries list]].<br />
<br />
<br />
== Missing libraries (by problem domain) ==<br />
<br />
=== IMAP ===<br />
A functional IMAP library would be nice, particularly one that can be used in conjunction with encryption and authentication. References have been found to a SoC project although it appears to be derelict. <br />
<br />
=== Numerical algorithms ===<br />
Stuff to compute bessel functions, struve H1 etc.<br />
<br />
=== .NET/Java Interoperability ===<br />
We could use a .NET FFI library that lets you easily call into the .NET framework. Perhaps the (abandoned?) [http://galois.com/~sof/hugs98.net/ Hugs .NET FFI library] could be resurrected/updated and ported to GHC? Maybe a tool could even be created that automates the interoperability of Haskell and arbitrary .NET libraries?<br />
<br />
: I'm working on a Haskell to .NET bridge for my undergraduate thesis. The goal is to provide access to arbitrary .NET libraries from Haskell, with a convenient syntax. I expect to have something releasable in a few weeks. [[User:AndrewA|AndrewA]] 13:33, 6 October 2007 (UTC)<br />
<br />
=== AMQP Client ===<br />
It will be great to have a client for the open source protocol AMQ (http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol). This is a new transport protocol, solving problems currently addressed by Java Messaging Service, MQ, Tibco RV, etc. Financial companies such infrastructure to distribute massive amounts of market data (although the protocol can be used for effeciently distributing anything)<br />
<br />
=== STOMP Client ===<br />
The Streaming Text Orientated Messaging Protocol (http://stomp.codehaus.org/) is a messaging protocol supported by a good number of languages and message brokers. While not high-performance like AMQP it is apparently near trivial to implement and interact with.<br />
<br />
=== Darcs Bindings ===<br />
Many darcs users have requested an interface to darcs as a C library. Creating this library would involve deciding on the details of the API and generating the bindings using the Haskell FFI. Designing the API is mostly done for you by following the structure of the darcs source code and how the existing commands interface with the core of darcs.<br />
<br />
== Could be improved ==<br />
<br />
Problems with existing solutions, that could be improved.<br />
<br />
* The core HTTP libraries need a lot of work. There is the beginnings of a useful library there, but many http codes are not handled, and there should be simple 'get' and 'head' functionality. <br />
* Binary serialisation support should be ported to bytestring, and added to the extralibs bundle<br />
* Support for wider Word values in bytestring.<br />
* Adding bytestring support to Parsec.<br />
* Simple process forking/popen, of type <hask>String -> IO String</hask>, is needed (the implementation should be in base)<br />
<br />
If you have code that improves on something in the base libraries, you might consider [[Library_submissions|submitting it to the libraries process]], so it can appear in the standard libraries.<br />
<br />
== Existing libraries (by problem domain) ==<br />
<br />
See [[Libraries_and_tools|the full libraries list]].<br />
<br />
=== GUIs ===<br />
<br />
See [[Libraries_and_tools/GUI_libraries|GUI libraries]]<br />
<br />
=== High performance string IO ===<br />
<br />
See [[Libraries_and_tools/Data_structures#Strings|String libraries]]<br />
<br />
=== Binary IO ===<br />
<br />
See [[Libraries_and_tools/Data_structures#Serialising_data|Binary IO]]<br />
<br />
=== Compression ===<br />
<br />
See [[Libraries_and_tools/Data_structures#Compressing_data|Compressing data]]<br />
<br />
=== Encryption ===<br />
<br />
See [[Libraries_and_tools/Cryptography|Crypto libraries]]<br />
<br />
=== Web frameworks ===<br />
<br />
See [[Libraries_and_tools/Web_programming#Web_frameworks|Web frameworks]]<br />
<br />
=== XML processing ===<br />
<br />
See [[Libraries_and_tools/Web_programming#XML|XML handling]]<br />
<br />
=== Database access ===<br />
<br />
See [[Libraries_and_tools/Database_interfaces|Databases]]<br />
<br />
== Libraries to package ==<br />
<br />
Several cool libraries are out there, not yet in hackage / cabal format.<br />
Some on the hitlist , that would be great to package up would be:<br />
<br />
* [http://www.eyrie.org/~zednenem/2004/hsce/Control.Comonad.html Control.Comonad]<br />
* [http://okmij.org/ftp/Computation/monads.html#LogicT LogicT]<br />
* [http://okmij.org/ftp/Computation/monads.html#random-var-monad probabilistic monads]<br />
* one of the libcurl bindings, either http://code.haskell.org/curl/ or better yet the SoC work at http://google-summer-of-code-2007-haskell.googlecode.com/files/Mieczyslaw_Bak.tar.gz.<br />
<br />
== C libraries ==<br />
<br />
C libraries are often very popular, and cheap to bind to. A good task<br />
would be to just write bindings to C libraries, sorted by popularity.<br />
<br />
Possible library rankings are provided by:<br />
<br />
* Debian packages ranked by:<br />
** [http://popcon.debian.org/source/by_inst Installations]<br />
** [http://popcon.debian.org/source/by_vote Votes]</div>Bjornhttps://wiki.haskell.org/index.php?title=AmeroHaskell&diff=16894AmeroHaskell2007-11-18T03:23:45Z<p>Bjorn: Added self to list</p>
<hr />
<div>AmeroHaskell, a Haskell get together for/in the SouthEastern USA.<br />
Now a Haskell get together(s) anywhere in the USA with at least one in Portland, OR.<br />
<br />
== Likely Attendees ==<br />
<br />
* [[ShaeErisson]] - located in Tuscaloosa, Alabama - pretty much any date is good for me.<br />
* [http://www.travishartwell.net/blog/ Travis B. Hartwell] aka Nafai<br />
* [http://byorgey.wordpress.com Brent Yorgey] (byorgey) - Washington, DC. Willing to travel some, probably can't take any time off of work but most weekends are good except Nov. 2-4 and 16-18.<br />
* [[DonStewart]], in OR, but would travel for haskell<br />
* [[Derek Elkins]], in TX, would travel some, probably would only stay for a day or two.<br />
* [[Dino]] Morelli - Raleigh, North Carolina. Will travel some, can stay somewhere overnight(s). Week of Oct 13-20 is not doable.<br />
* [[Betty]] - Raleigh, NC<br />
* [[User:CliffordBeshers|CliffordBeshers]] - San Diego, CA, but would consider travelling.<br />
* [[JohnMeacham]] - Pasadena, CA. might be able to travel depending on when. (would prefer somewhere on west coast)<br />
* [[GregFitzgerald]] - San Diego, CA<br />
* [[Adam Peacock]] - NYC, I might come, but Nov 24 to Dec 9 I'm traveling elsewhere.<br />
* [[Peter Gavin]] - Tallahassee, FL, willing to drive a few hours; weekends are best<br />
* [[Bernard Putersznit]] - Ocala, FL, willing to drive a few hours; any day of the week. Available from November onward.<br />
* [[Rahul Kapoor]] - Providence, RI, will travel for Haskell.<br />
* [[BryanOSullivan]] - San Francisco, CA, will travel.<br />
* [[TimChevalier]] - Portland, OR. Might be willing to travel, depending on where and when.<br />
* [[User:Taral|Taral]] - Seattle, WA, will travel.<br />
* [[Bjorn Buckwalter]] - Washington, DC. Unlikely to travel.<br />
<br />
== Possible locations ==<br />
<br />
* Portland, OR<br />
* Although this is in the North East, Credit Suisse - contact Adam Peacock<br />
<br />
== Potential Presenters ==<br />
<br />
* [[Derek Elkins]] - I can provide a talk for categorical ideas that are directly applicable in Haskell (e.g. free monads, initial algebras, etc.) and/or something on using types to enforce invariants without going ''too'' crazy (e.g. wrapper types, phantom types, type class traits, reasonable examples of type level programming)<br />
* [[TimChevalier]] - if you're really hard up for speakers, I could scrape something up.<br />
<br />
== When ==<br />
<br />
* For a Portland meeting, probably in a January/February time-frame<br />
* Maybe during SIGCSE in Portland March 12-15<br />
<br />
[[Category:Events]]</div>Bjornhttps://wiki.haskell.org/index.php?title=Applications_and_libraries/Mathematics&diff=10799Applications and libraries/Mathematics2007-01-27T21:35:15Z<p>Bjorn: Added 'Dimensional' library to the Physical Units section.</p>
<hr />
<div>== Applications ==<br />
<br />
=== Physics ===<br />
<br />
;[http://ab-initio.mit.edu/meep/ Meep]<br />
:Meep (or MEEP) is a free finite-difference time-domain (FDTD) simulation software package developed at MIT to model electromagnetic systems.<br />
<br />
;[[Numeric Quest]]<br />
:Jan Skibinski's [[Numeric Quest]] library provides modules that are useful for Quantum Mechanics, among other things.<br />
<br />
== Libraries ==<br />
<br />
=== Linear algebra ===<br />
<br />
;[http://dis.um.es/~alberto/GSLHaskell GSLHaskell]<br />
:High level functional interface to standard linear algebra computations and other numerical algorithms based on the GNU Scientific Library. Includes numerical differentiation, integration, Fourier transforms, polynomial root-finding, and support for gnuplot. [http://alberrto.googlepages.com/gslhaskell Alternative download site], [[GSLHaskell on MacOS X|MacOS X]].<br />
<br />
;[http://www.cs.utah.edu/~hal/HBlas/index.html Wrapper to CLAPACK]<br />
<br />
;[http://haskelldsp.sourceforge.net/ Digital Signal Processing]<br />
:Modules for matrix manipulation, digital signal processing, spectral estimation, and frequency estimation.<br />
<br />
;[http://article.gmane.org/gmane.comp.lang.haskell.general/13561 Index-aware linear algebra]<br />
:Frederik Eaton's library for statically checked matrix manipulation in Haskell<br />
<br />
;[[Numeric Quest]]<br />
:Jan Skibinski's [[Numeric Quest]] library provides several modules that are useful for linear algebra in general, among other things.<br />
<br />
<br />
See also: [[Linear algebra|Design discussions]]<br />
<br />
=== [[Physical units]] ===<br />
<br />
;[[Dimensionalized numbers]]<br />
: Working with physical units like second, meter and so on in a type-safe manner.<br />
<br />
;[http://darcs.haskell.org/numericprelude/src/Number/SI.hs NumericPrelude: Physical units]<br />
: Numeric values with dynamically checked units.<br />
<br />
;[[CalDims]]<br />
:This is not simply a library providing a new type of <hask>Num</hask> class, but stand-alone calculation tool that supports user defined functions and units (basic and derrived), so it can provide dimension-save calculation (not embedded but via shell). Calculations can be modified/saved via shell. It uses rational numbers to avoid rounding errors where possible.<br />
<br />
;[http://code.google.com/p/dimensional/ Dimensional]<br />
: Library providing data types for performing arithmetic with physical quantities and units. Information about the physical dimensions of the quantities/units is embedded in their types and the validity of operations is verified by the type checker at compile time. The boxing and unboxing of numerical values as quantities is done by multiplication and division of units.<br />
<br />
=== Number representations ===<br />
<br />
==== Decimal numbers ====<br />
<br />
;[http://www.n-heptane.com/nhlab/repos/Decimal Decimal arithmetic library]<br />
:An implementation of real decimal arithmetic, for cases where the binary floating point is not acceptable (for example, money).<br />
<br />
==== Real and rational numbers ====<br />
<br />
There are several levels of [[Exact real arithmetic|handling real numbers]] and according libraries.<br />
<br />
===== Arbitrary precision =====<br />
<br />
* Numbers have fixed precision<br />
* Rounding errors accumulate<br />
* Sharing is easy, i.e. in <hask>sqrt pi + sin pi</hask>, <hask>pi</hask> is computed only once<br />
* Fast, because the routines can make use of the fast implementation of <hask>Integer</hask> operations<br />
<br />
;[[Numeric Quest]]<br />
:Jan Skibinski's [[Numeric Quest]] library provides, among other things, a type for arbitrary precision rational numbers with transcendental functions.<br />
<br />
;[http://cvs.haskell.org/darcs/numericprelude/src/Number/FixedPoint.hs FixedPoint.hs]<br />
:part of NumericPrelude project<br />
<br />
===== Dynamic precision =====<br />
<br />
* You tell the precision, an expression shall be computed to and the computer finds out, how precise to compute the input values.<br />
* Rounding errors do not accumulate<br />
* Sharing of temporary results is difficult, that is in <hask>sqrt pi + sin pi</hask>, <hask>pi</hask> will certainly be computed twice, each time with the required precision.<br />
* Almost as fast as arbitrary precision computation<br />
<br />
;[http://www.cs.man.ac.uk/arch/dlester/exact.html ERA] is an implementation (in Haskell 1.2) by David Lester.<br />
:It is quite fast, possibly the fastest Haskell implementation. At 220 lines it is also the shortest. Probably the shortest implementation of exact real arithmetic in any language.<br />
:Here is a mirror: http://darcs.augustsson.net/Darcs/CReal/<br />
<br />
;[http://www.doc.ic.ac.uk/~ae/exact-computation/#bm:implementations IC-Reals] is an implementation by Abbas Edalat, Marko Krznar&#263; and Peter J. Potts.<br />
:This implementation uses linear fractional transformations.<br />
<br />
;[http://r6.ca/ Few Digits] by Russell O'Connor.<br />
:This is a prototype of the implementation he intendeds to write in [http://coq.inria.fr/ Coq]. Once the Coq implementation is complete, the Haskell code could be extracted producing an implementation that would be proved correct.<br />
<!--<br />
Example:<br />
*Data.Real.CReal> answer 1000 (exp 1 + sqrt 2)<br />
--><br />
<br />
;COMP is an implementation by Yann Kieffer.<br />
:The work is in beta and relies on new primitive operations on Integers which will be implemented in GHC. The library isn't available yet.<br />
<br />
===== Dynamic precision by lazy evaluation =====<br />
<br />
The real numbers are represented by an infinite datastructure, which allows you to increase precision successively by evaluating the data structure successively. All of the implementations below use some kind of digit stream as number representation.<br />
Sharing of results is simple.<br />
The implementations are either fast on simple expressions, because they use large blocks/bases, or they are fast on complex expressions, because they consume as little as possible input digits in order to emit the required output digits.<br />
<br />
;[http://medialab.freaknet.org/bignum/ BigFloat] is an implementation by Martin Guy.<br />
:It works with streams of decimal digits (strictly in the range from 0 to 9) and a separate sign. The produced digits are always correct. Output is postponed until the code is certain what the next digit is. This sometimes means that [http://medialab.freaknet.org/bignum/dudeney.html no more data is output].<br />
<br />
;In [http://users.info.unicaen.fr/~karczma/arpap/lazypi.ps.gz "The Most Unreliable Technique in the World to compute pi"] Jerzy Karczmarczuk develops some functions for computing pi lazily.<br />
<br />
;[http://darcs.haskell.org/numericprelude/src/Number/Positional.hs NumericPrelude: positional numbers]<br />
:Represents a real number as pair <hask>(exponent,[digit])</hask>, where the digits are <hask>Int</hask>s in the open range <hask>(-basis,basis)</hask>. There is no need for an extra sign item in the number data structure. The <hask>basis</hask> can range from <hask>10</hask> to <hask>1000</hask>. (Binary representations can be derived from the hexadecimal representation.) Showing the numbers in traditional format (non-negative digits) fails for fractions ending with a run of zeros. However the internal representation with negative digits can always be shown and is probably more useful for further processing. An interface for the numeric type hierarchy of the NumericPrelude project is provided.<br />
:It features<br />
:* basis conversion<br />
:* basic arithmetic: addition, subtraction, multiplication, division<br />
:* algebraic arithmetic: square root, other roots (no general polynomial roots)<br />
:* transcendental arithmetic: pi, exponential, logarithm, trigonometric and inverse trigonometric functions<br />
<br />
=== Type class hierarchies ===<br />
<br />
There are several approaches to improve the [[Mathematical prelude discussion|numeric type class hierarchy]].<br />
<br />
;Dylan Thurston and Henning Thielemann's [http://cvs.haskell.org/darcs/numericprelude/ Numeric Prelude]<br />
:Experimental revised framework for numeric type classes. Needs hiding of Prelude, overriding hidden functions like fromInteger and multi-parameter type classes. Probably restricted to GHC.<br />
<br />
;Jerzy Karczmarczuk's [http://www.haskell.org/pipermail/haskell-cafe/2001-February/001510.html approach]<br />
<br />
;Serge D. Mechveliani's [ftp://ftp.botik.ru/pub/local/Mechveliani/basAlgPropos/ Basic Algebra proposal]<br />
<br />
;Andrew Frank's [http://www.haskell.org/pipermail/haskell-cafe/2006-April/015326.html approach]<br />
:The proposal: ftp://ftp.geoinfo.tuwien.ac.at/frank/numbersPrelude_v1.pdf<br />
<br />
;Haskell Prime: [http://hackage.haskell.org/trac/haskell-prime/ticket/112 Ongoing efforts for the language revision]<br />
<br />
=== Discrete mathematics ===<br />
<br />
;[http://andrew.bromage.org/darcs/numbertheory/ Number Theory Library]<br />
:Andrew Bromage's Haskell number theory library, providing operations on primes, fibonacci sequences and combinatorics.<br />
<br />
;[http://users.skynet.be/jyp/HGAL/ HGAL]<br />
:An haskell implementation of Brendan McKay's algorithm for graph canonic labeling and automorphism group. (aka Nauty)<br />
<br />
;[http://www.cambridge.org/uk/catalogue/catalogue.asp?isbn=0521849306 Computational Oriented Matroids]<br />
:is a book by [http://wwwopt.mathematik.tu-darmstadt.de/~bokowski/ Jürgen G. Bokowski], where he develops Haskell code for Matroid computations.<br />
<br />
See also [[Libraries and tools/Cryptography]]<br />
<br />
=== Computer Algebra ===<br />
<br />
;[http://haskell.org/docon/ DoCon] - Algebraic Domain Constructor<br />
:A library for Algebra, turns GHCi into a kind of Computer Algebra System<br />
<br />
;[http://www.info.unicaen.fr/~karczma/arpap/ Papers by Jerzy Karczmarczuk]<br />
:Some interesting uses of Haskell in mathematics, including functional differentiation, power series, continued fractions.<br />
<br />
=== Miscellaneous libraries ===<br />
<br />
;[http://www.robtougher.com/HaskellMath/ HaskellMath]<br />
:The HaskellMath library is a sandbox for experimenting with mathematics algorithms. So far I've implemented a few quantitative finance models (Black Scholes, Binomial Trees, etc) and basic linear algebra functions. Next I might work on either computer algebra or linear programming. All comments welcome!<br />
<br />
;[http://www.polyomino.f2s.com/david/haskell/codeindex.html Haskell for Maths]<br />
:David Amos' [http://www.polyomino.f2s.com/david/haskell/main.html collection of math libraries] in Haskell - including number theory, commutative algebra, combinatorics, permutation groups and more.<br />
<br />
;[http://darcs.haskell.org/htam/ Various math stuff by Henning Thielemann]<br />
:This is some unsorted mathematical stuff including: GNUPlot wrapper, portable grey map (PGM) image reader and writer, simplest numerical integration, differentiation, zero finding, interpolation, solution of differential equations, combinatorics, some solutions of math riddles, computation of fractal dimensions of iterated function systems (IFS)<br />
<br />
;[[Numeric Quest]]<br />
:Jan Skibinski wrote a collection of Haskell modules that are useful for Mathematics in general, and Quantum Mechanics in particular.<br />
<br />
:Some of the modules are hosted on [http://darcs.haskell.org/numeric-quest/ haskell.org]. They include modules for:<br />
:* Rational numbers with transcendental functions<br />
:* Roots of polynomials<br />
:* Eigensystems<br />
:* Tensors<br />
:* Dirac quantum mechanics<br />
<br />
:Other modules in Numeric Quest are currently only available via the [http://web.archive.org/web/20010605003250/http://www.numeric-quest.com/haskell/ Internet Archive]. They include, among many other things:<br />
:* [http://web.archive.org/web/*/http://www.numeric-quest.com/haskell/ State vector evolution]<br />
:* [http://web.archive.org/web/*/http://www.numeric-quest.com/haskell/ Short study of fuzzy oscillator]<br />
<br />
:See the [[Numeric Quest]] page for more information.<br />
<br />
;[http://www.dinkla.net/fp/cglib.html Geometric Algorithms]<br />
:A small Haskell library, containing algorithms for two-dimensional convex hulls, triangulations of polygons, Voronoi-diagrams and Delaunay-triangulations, the QEDS data structure, kd-trees and range-trees.<br />
<br />
;[http://repetae.net/john/recent/out/HsASA.html Adaptive Simulated Annealing]<br />
:A Haskell interface to Lester Ingber's adaptive simulating annealing code.<br />
<br />
;[http://www.solcon.nl/mklooster/repos/hmm/ Hmm: Haskell Metamath]<br />
:Hmm is a small Haskell library to parse and verify Metamath databases.<br />
<br />
;[http://eecs.oregonstate.edu/~erwig/pfp/ Probabilistic Functional Programming]<br />
:The PFP library is a collection of modules for Haskell that facilitates probabilistic functional programming, that is, programming with stochastic values. The probabilistic functional programming approach is based on a data type for representing distributions. A distribution represent the outcome of a probabilistic event as a collection of all possible values, tagged with their likelihood. A nice aspect of this system is that simulations can be specified independently from their method of execution. That is, we can either fully simulate or randomize any simulation without altering the code which defines it.<br />
<br />
;[[Sinc function]]<br />
<br />
;[http://repetae.net/john/recent/out/Boolean.html Boolean]<br />
:A general boolean algebra class and some instances for Haskell.<br />
<br />
;[http://darcs.haskell.org/~lemmih/hode/ HODE]<br />
:HODE is a binding to the Open Dynamics Engine. ODE is an open source, high performance library for simulating rigid body dynamics.<br />
<br />
;[http://sourceforge.net/projects/ranged-sets Ranged Sets]<br />
:A ranged set is a list of non-overlapping ranges. The ranges have upper and lower boundaries, and a boundary divides the base type into values above and below. No value can ever sit on a boundary. So you can have the set <math>(2.0, 3.0] \cup (5.3, 6)</math>.<br />
<br />
[[Category:Mathematics]]<br />
{{LibrariesPage}}</div>Bjornhttps://wiki.haskell.org/index.php?title=Physical_units&diff=10787Physical units2007-01-27T19:17:34Z<p>Bjorn: Added my 'Dimensional' library to the list.</p>
<hr />
<div>How would one go about modeling units (seconds, meters, meters per second, etc) in Haskell? I'm particularly interested in getting the typechecker to verify proper usage, and do not want to restrict it to any particular numeric representation (i.e. both integral seconds and fractional seconds). If this can in fact be done, it could also be used to model coordinate system axes in, say, Geometric Algebra.<br />
<br />
* It can. Look at [[Dimensionalized numbers]] for a toy implementation. I've thought a bit about the Geometric Algebra case, but I can't see a good way of handling it without forcing a choice of basis. I'm also not sure how it would work -- the whole point of GA is to incorporate areas, lengths, volumes, etc. into one number type. I suppose we could use this type of technique to segregate GA spaces with different dimensions or even metrics. --AaronDenney<br />
<br />
* A (non-toy) implementation of statically checked physical dimensions with a complete set of dimensions (but limited number of predefined units) is [http://code.google.com/p/dimensional/ Dimensional]. I apologize for coming up with the same name as Aaron and am on the lookout for a new one. I cannot comment on the applicability to GA. --[[User:Bjorn|Bjorn]]<br />
<br />
* NumericPrelude also contains an implementation of values equipped with physical units. However all unit checking is made dynamically, that is expressions like <hask>1 * meter < 2 * second</hask> are accepted by the Haskell compiler but lead to a runtime error. This design allows multiplication of values with different units, but prohibits catching unit errors at compile time. Units are handled as integer vectors of exponents of base units. Computation with these vectors is rather simple, however formatting them is difficult. Formatting and parsing values with units is supported. A small library of SI units is provided.<br />
: http://darcs.haskell.org/numericprelude/src/Number/Physical.hs<br />
: http://darcs.haskell.org/numericprelude/src/Number/SI.hs<br />
<br />
:Get with <code>darcs get http://darcs.haskell.org/numericprelude/</code><br />
<br />
* [[CalDims]]<br />
<br />
<br />
[[Category:Mathematics]]</div>Bjorn