Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recipe parallelism #1

Open
t0yv0 opened this issue Nov 2, 2013 · 0 comments
Open

Recipe parallelism #1

t0yv0 opened this issue Nov 2, 2013 · 0 comments

Comments

@t0yv0
Copy link
Contributor

t0yv0 commented Nov 2, 2013

Recipe<'T> is a monad describing build actions. It currently conceptually involves state monad transformer over Async, primarily to track traversed targets. It should be relatively easy to add implicit parallelism using .Combine and Applicative operators (as can be done for plain Async, see 1).

Examples of desired implicit parallelism:

type Recipe<'T> // describes how to cook a 'T
type Target<'T> // describes a target producing a 'T
val Recipe.Pure : 'T -> Recipe<'T>
val Recipe.(<*>) : Recipe<'A -> 'B> -> Recipe<'A> -> Recipe<'B> 
val Recipe.Require : Target<'T> -> Recipe<'T>

// Non-monadic composition  hopefully compiles to .Combine
// which unlike Bind can be made parallel:
Recipe.Do {
  do! Recipe.Require Target1 // assuming Target<unit>
  do! Recipe.Require Target2
  ... 
}

// Applicative composition always can be parallel:

Recipe.Pure (fun x y z -> f (x, y, z))
<*> Recipe1
<*> Recipe2
<*> Recipe3

Interaction with logging: logging should not be a side-effect embedded into Async but instead a dedicated concept in Recipe<'T>. The idea is to execute a <*> b in parallel, but produce logs always in order - left-to-right, as soon as available.

Interaction with error reporting: can treat exceptions the same way as Async.Parallel - not sure if it currently reports the leftmost exception or combines them into AggregateException. I think the leftmost makes more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant