# Rational

Arbitrary-precision rational numbers, represented as a ratio of two Integer values. A rational number may be constructed using the % operator.
Read a rational number. This function accepts an optional leading sign character, followed by at least one decimal digit. The syntax similar to that accepted by the read function, with the exception that a trailing '.' or 'e' not followed by a number is not consumed. Examples (with behaviour identical to read): > rational "3" == Right (3.0, "") > rational "3.1" == Right (3.1, "") > rational "3e4" == Right (30000.0, "") > rational "3.1e4" == Right (31000.0, "") > rational ".3" == Left "input does not start with a digit" > rational "e3" == Left "input does not start with a digit" Examples of differences from read: > rational "3.foo" == Right (3.0, ".foo") > rational "3e" == Right (3.0, "e")
Read a rational number. This function accepts an optional leading sign character, followed by at least one decimal digit. The syntax similar to that accepted by the read function, with the exception that a trailing '.' or 'e' not followed by a number is not consumed. Examples: > rational "3" == Right (3.0, "") > rational "3.1" == Right (3.1, "") > rational "3e4" == Right (30000.0, "") > rational "3.1e4" == Right (31000.0, "") > rational ".3" == Left "input does not start with a digit" > rational "e3" == Left "input does not start with a digit" Examples of differences from read: > rational "3.foo" == Right (3.0, ".foo") > rational "3e" == Right (3.0, "e")
approxRational, applied to two real fractional numbers x and epsilon, returns the simplest rational number within epsilon of x. A rational number y is said to be simpler than another y' if * abs (numerator y) <= abs (numerator y'), and * denominator y <= denominator y'. Any real interval contains a unique simplest rational; in particular, note that 0/1 is the simplest rational of all.
package
A reimplementation of the operational package (http://hackage.haskell.org/package/operational) using free monads (from http://hackage.haskell.org/package/free). This implements ideas discussed here: * http://stackoverflow.com/questions/14263363/is-operational-really-isomorphic-to-a-free-monad * http://www.reddit.com/r/haskell/comments/17a33g/free_functors_the_reason_free_and_operational_are/ To understand the basic concepts you can do no better than read Heinrich Apfelmus' operational tutorial: * http://apfelmus.nfshost.com/articles/operational-monad.html In addition to that, this package supplies operational-style modules for Applicative, Alternative and MonadPlus. Applicative and Alternative programs easily admit of static analysis.  See these references for discussion and examples: * http://gergo.erdi.hu/blog/2012-12-01-static_analysis_with_applicatives/ (discussion: http://www.reddit.com/r/haskell/comments/143wpd/static_analysis_with_applicatives/) * http://paolocapriotti.com/blog/2013/04/03/free-applicative-functors/ (discussion: http://www.reddit.com/r/haskell/comments/1bnql3/free_applicative_functors_icfp_submission/) See Control.Applicative.Operational for the bulk of the documentation. Control.Alternative.Operational also has some significant examples. Version 0.5.0.0
package
This package provides tiny implementation of operational monad. Version 0.4.2
package
This library makes it easy to implement monads with tricky control flow. This is useful for: writing web applications in a sequential style, programming games with a uniform interface for human and AI players and easy replay capababilities, implementing fast parser monads, designing monadic DSLs, etc. See the project homepage http://haskell.org/haskellwiki/Operational for a more detailed introduction and features. Related packages: MonadPrompt http://hackage.haskell.org/package/MonadPrompt. Version 0.2.2.1