Stability | Portability : concurrency |
---|---|

Maintainer | John Launchbury <john@galois.com> |

Safe Haskell | None |

- signal :: Orc ()
- cut :: Orc a -> Orc a
- onlyUntil :: Orc a -> Orc b -> Orc b
- butAfter :: Orc a -> (Float, Orc a) -> Orc a
- timeout :: Float -> a -> Orc a -> Orc a
- silent :: Orc a -> Orc b
- liftList :: MonadPlus list => [a] -> list a
- repeating :: Orc a -> Orc a
- runChan :: Chan a -> Orc a -> IO ()
- sync :: (a -> b -> c) -> Orc a -> Orc b -> Orc c
- notBefore :: Orc a -> Float -> Orc a
- syncList :: [Orc a] -> Orc [a]
- delay :: (RealFrac a, Show a) => a -> Orc ()
- printOrc :: Show a => Orc a -> IO ()
- prompt :: String -> Orc String
- putStrLine :: String -> Orc ()
- scan :: (a -> s -> s) -> s -> Orc a -> Orc s
- (<?>) :: Orc a -> Orc a -> Orc a
- count :: Orc a -> Orc (Either a Int)
- collect :: Orc a -> Orc [a]
- takeOrc :: Int -> Orc a -> Orc a
- dropOrc :: Int -> Orc a -> Orc a
- zipOrc :: Orc a -> Orc b -> Orc (a, b)
- sandbox :: Orc a -> MVar (Maybe a) -> MVar () -> Orc ()
- echo :: Int -> MVar (Maybe a) -> MVar () -> Orc a
- zipp :: MVar (Maybe a) -> MVar (Maybe b) -> MVar () -> Orc (a, b)
- publish :: NFData a => a -> Orc a

# Documentation

Alternate phrasing of `return ()`

, which can be placed at the end
of an Orc computation to signal that it has no more values to
produce.

Cut executes an orc expression, waits for the first result, and then suppresses the rest, including killing any threads involved in computing the remainder.

onlyUntil :: Orc a -> Orc b -> Orc bSource

Executes the computation `p`

and `done`

. Once `done`

returns its
first result, kill both computations and returns that result. This
discards the results of `p`

.

butAfter :: Orc a -> (Float, Orc a) -> Orc aSource

Immediately executes the computation `p`

, but if it hasn't returned
a result in `t`

seconds, execute the computation `q`

and return
whichever computations returns a result first (killing the other
thread).

timeout :: Float -> a -> Orc a -> Orc aSource

Executes a computation `p`

, but if it hasn't returned a result in
`n`

seconds return `a`

instead (killing the `p`

computation).

repeating :: Orc a -> Orc aSource

Repeatedly executes the computation `p`

and returns its
results. `repeating`

works best when `p`

is single-valued:
if `p`

is multivalued Orc will spawn a repeating thread for every
result returned, resulting in an exponential blow-up of
threads (XXX: I don't think this was actually intended.)

runChan :: Chan a -> Orc a -> IO ()Source

Runs a computation `p`

and writes its results to the channel `ch`

.

sync :: (a -> b -> c) -> Orc a -> Orc b -> Orc cSource

Takes the first result of `p`

, the first result of
`q`

, and applies them to `f`

. The computations for `p`

and `q`

are
run in parallel.

notBefore :: Orc a -> Float -> Orc aSource

Runs the computation `p`

and returns its first result, but doesn't
return before `w`

seconds have elapsed.

syncList :: [Orc a] -> Orc [a]Source

Runs a list of Orc computations `ps`

in parallel until they produce
their first result, and returns a list of all these results.

delay :: (RealFrac a, Show a) => a -> Orc ()Source

Wait for a period of w seconds, then continue processing.

printOrc :: Show a => Orc a -> IO ()Source

Runs an Orc computation, eagerly printing out the results of an Orc computation line-by-line.

putStrLine :: String -> Orc ()Source

Writes a string and newline to standard output. Concurrency-safe.

scan :: (a -> s -> s) -> s -> Orc a -> Orc sSource

Analogous to the list scan function, but the order in which
the combining function is applied to the results produced by
`p`

is nondeterministic.

(<?>) :: Orc a -> Orc a -> Orc aSource

A variant of `<+>`

, pronounced or-else, which performs and returns
the results of `p`

, and if `p`

produced no answers go on and performa
dn return the results of `q`

.

count :: Orc a -> Orc (Either a Int)Source

For each value produced by `p`

, return a `Left a`

. Once `p`

has
finished, return a `Right Int`

containing the number of results
produced.

collect :: Orc a -> Orc [a]Source

Collects all of the values of the computation `p`

and delivers them
as a list when `p`

is completed.

takeOrc :: Int -> Orc a -> Orc aSource

List-like functions

Runs the computation `p`

and returns the first `n`

results.

dropOrc :: Int -> Orc a -> Orc aSource

Drops the first `n`

results of the computation `p`

, and then
returns the rest of the results.

zipOrc :: Orc a -> Orc b -> Orc (a, b)Source

Zips the results of two computations `p`

and `q`

. When one
computation finishes, kill the other.