tree-monad (empty) → 0.1
raw patch · 5 files changed
+103/−0 lines, 5 filesdep +basesetup-changed
Dependencies added: base
Files
- Control/Monad/SearchTree.hs +42/−0
- LICENSE +15/−0
- README +12/−0
- Setup.hs +4/−0
- tree-monad.cabal +30/−0
+ Control/Monad/SearchTree.hs view
@@ -0,0 +1,42 @@+-- |+-- Module : Control.Monad.SearchTree+-- Copyright : Sebastian Fischer+-- License : PublicDomain+-- +-- Maintainer : Sebastian Fischer (sebf@informatik.uni-kiel.de)+-- Stability : experimental+-- Portability : portable+-- +-- This Haskell library provides an implementation of the MonadPlus+-- type class that represents the search space as a tree whose+-- constructors represent mzero, return, and mplus.+-- +-- Such a tree can be used to implement different search strategies,+-- e.g., by using a queue. It can also be used as a basis for parallel+-- search strategies that evaluate different parts of the search space+-- concurrently.++module Control.Monad.SearchTree ( SearchTree(..) ) where++import Control.Monad++-- | +-- The type @SearchTree a@ represents non-deterministic computations+-- as a tree structure.+data SearchTree a = None | One a | Choice (SearchTree a) (SearchTree a)++instance Monad SearchTree+ where+ return = One++ None >>= _ = None+ One x >>= f = f x+ Choice s t >>= f = Choice (s >>= f) (t >>= f)++ fail _ = None++instance MonadPlus SearchTree+ where+ mzero = None+ mplus = Choice+
+ LICENSE view
@@ -0,0 +1,15 @@+ALL PUBLIC DOMAIN MATERIAL IS OFFERED AS-IS. NO REPRESENTATIONS OR+WARRANTIES OF ANY KIND ARE MADE CONCERNING THE MATERIALS, EXPRESS,+IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION,+WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR+PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS,+ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT+DISCOVERABLE.++IN NO EVENT WILL THE AUTHOR(S), PUBLISHER(S), OR PRESENTER(S) OF ANY+PUBLIC DOMAIN MATERIAL BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY+SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES+ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF THE+AUTHOR(S), PUBLISHER(S), OR PRESENTER(S) HAVE BEEN ADVISED OF THE+POSSIBILITY OF SUCH DAMAGES.+
+ README view
@@ -0,0 +1,12 @@+Non-Determinism Monad for Tree Search+=====================================++This Haskell library provides an implementation of the MonadPlus type+class that represents the search space as a tree whose constructors+represent mzero, return, and mplus.++Such a tree can be used to implement different search strategies,+e.g., by using a queue. It can also be used as a basis for parallel+search strategies that evaluate different parts of the search space+concurrently.+
+ Setup.hs view
@@ -0,0 +1,4 @@+import Distribution.Simple++main = defaultMain+
+ tree-monad.cabal view
@@ -0,0 +1,30 @@+Name: tree-monad+Version: 0.1+Cabal-Version: >= 1.6+Synopsis: Non-Determinism Monad for Tree Search+Description: ++ This Haskell library provides an implementation of the MonadPlus+ type class that represents the search space as a tree whose+ constructors represent mzero, return, and mplus.++Category: Control, Monads+License: PublicDomain+License-File: LICENSE+Author: Sebastian Fischer+Maintainer: sebf@informatik.uni-kiel.de+Bug-Reports: mailto:sebf@informatik.uni-kiel.de+Homepage: http://github.com/sebfisch/tree-monad+Build-Type: Simple+Stability: experimental++Extra-Source-Files: README++Library+ Build-Depends: base+ Exposed-Modules: Control.Monad.SearchTree+ Ghc-Options: -Wall++Source-Repository head+ type: git+ location: git://github.com/sebfisch/tree-monad.git