The nondeterminism package

[Tags: lgpl, library]

Nondeterministic computations


[Skip to ReadMe]

Properties

Version1.0
Change logNone available
Dependenciesbase (>=3 && <5), containers, mtl (>=2) [details]
LicenseLGPL
AuthorAndrei Barbu <andrei@0xab.com>
MaintainerAndrei Barbu <andrei@0xab.com>
CategoryControl, AI, Constraints, Failure, Monads
Source repositoryhead: git clone git://github.com/abarbu/nondeterminism-haskell.git
UploadedWed Aug 14 08:51:12 UTC 2013 by AndreiBarbu
Downloads325 total (23 in last 30 days)
Votes
0 []
StatusDocs uploaded by user
Build status unknown [no reports yet]

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for nondeterminism-1.0

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