File: TreeSearch.hs

package info (click to toggle)
haskell-parallel-tree-search 0.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 84 kB
  • sloc: haskell: 12; makefile: 7
file content (26 lines) | stat: -rw-r--r-- 826 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-- |
-- Module      : Control.Parallel.TreeSearch
-- Copyright   : Fabian Reck, Sebastian Fischer
-- License     : PublicDomain
--
-- Maintainer  : Niels Bunkenburg (nbu@informatik.uni-kiel.de)
-- Stability   : experimental
-- Portability : portable
--
-- This Haskell library provides an implementation of parallel search
-- based on the search tree provided by the package tree-monad.
--
module Control.Parallel.TreeSearch ( parSearch ) where

import           Control.Monad.SearchTree
import           Control.Parallel

-- | Enumerate the leaves of a @SearchTree@ using parallel depth-first search.
parSearch :: SearchTree a  -- ^ tree to search
          -> [a]           -- ^ lazy list of leaves

parSearch None = []
parSearch (One x) = [x]
parSearch (Choice l r) = rs `par` (parSearch l ++ rs)
 where
  rs = parSearch r