nondeterminism: A monad and monad transformer for nondeterministic computations.

[ ai, constraints, control, failure, library, monads ] [ Propose Tags ]

Nondeterministic computations


[Skip to Readme]

Modules

[Index]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0, 1.2, 1.4
Dependencies base (>=3 && <4.8), containers, mtl (>=2 && <2.3) [details]
License LicenseRef-LGPL
Author Andrei Barbu <andrei@0xab.com>
Maintainer Andrei Barbu <andrei@0xab.com>
Revised Revision 1 made by HerbertValerioRiedel at 2019-06-01T09:03:21Z
Category Control, AI, Constraints, Failure, Monads
Source repo head: git clone git://github.com/abarbu/nondeterminism-haskell.git
Uploaded by AndreiBarbu at 2013-08-14T08:51:12Z
Distributions LTSHaskell:1.4, NixOS:1.4, Stackage:1.4
Downloads 2776 total (9 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for nondeterminism-1.0

[back to package description]

Nondeterminism

This provides nondeterministic computations in Haskell. It implements an Amb monad in which you can perform nondeterministic choices along with a monad transformer version, AmbT.

Amb

An example which finds Pythagorean triplets up to a certain size, project Euler problem 9.

import Control.Monad
import Control.Monad.Amb
pyTriple :: (Num t, Ord t) => t -> Amb r (t, t, t)
pyTriple n = do a <- anIntegerBetween 1 n
                b <- anIntegerBetween (a + 1) n
                c <- anIntegerBetween (b + 1) n
                when (a*a + b*b /= c*c) fail'
                return (a,b,c)

length $ allValues $ pyTriple 10000

Future

  • Docs!