Questions tagged [hopac]

Hopac is a library for F# with the aim of making it easier to write correct, modular and efficient parallel, asynchronous and concurrent programs.

Hopac is a library for F# with the aim of making it easier to write correct, modular and efficient parallel, asynchronous and concurrent programs. The design of Hopac draws inspiration from languages such as Concurrent ML and Cilk. Similar to Concurrent ML, Hopac provides message passing primitives and supports the construction of first-class synchronous abstractions. Parallel jobs (lightweight threads) in Hopac are created using techniques similar to the F# Async framework. Similar to Cilk, Hopac runs parallel jobs using a work distributing scheduler in a non-preemptive fashion.

11 questions
4
votes
0 answers

Better understanding of F# Hopac library

I have started using Hopac as an alternative to Async/TPL and I love it. I understand basic usage, but some aspects are still not clear. First, could we compare Alt to F# lazy, so that a job inside an Alt is only evaluated on Alt.pick? Second, is…
V.B.
  • 6,236
  • 1
  • 33
  • 56
4
votes
0 answers

Hopac, how to implement a more nuanced MailboxProcessor?

I'm not sure if I should ask this here or the Hopac Wiki or if this is more like a design question, but here goes. I was recently researching F# agents to go with my Rx related coding and came across the following code How do I create a job queue…
Veksi
  • 3,556
  • 3
  • 30
  • 69
4
votes
1 answer

Hopac -- can I give value to a channel only if someone is listening to it?

Hopac allows to synchronously give value to a channel which will block if no-one is listening, and to asynchronously send which will buffer the values if they are not read. I would like to do something in-between: to give a value if there is a…
Arbil
  • 999
  • 1
  • 7
  • 15
2
votes
1 answer

F#- Using HttpFs.Client and Hopac: How do I get a response code, response headers and response cookies?

I am using F# with HttpFs.Client and Hopac. I am able to get Response body and value of each node of JSON/XML response by using code like: [] let ``Test a Create user API``() = let response = Request.createUrl Post…
2
votes
1 answer

How to unbox Async []

So I have an Async [] and for the life of me I can't figure out how to unbox it! I started with Job> [] Then I managed to get it to Job [] So I added in Job.toAsync thinking converting it to an async might be easier to…
DotNetRussell
  • 9,716
  • 10
  • 56
  • 111
1
vote
1 answer

Why are two bidirectional channels needed to implement the server protocol for a cell?

It may seem odd that two bidirectional channels are needed to implement the protocol. Couldn't we use just a single channel and change the server loop to give and take on that single channel. Note that this is allowed in Hopac and poses no problem.…
Marko Grdinić
  • 3,798
  • 3
  • 18
  • 21
1
vote
0 answers

Concatenate Jobs in Hopac

How you would become an Alt<'a> out of a Job<'a>? Or said others how one becomes one Alt<'a> from many, for example from an Alt<'a>[]? There is Job.conCollect , which returns Job<'a>, but nothing like Alt.conCollect which would return Alt<'a> let…
python_kaa
  • 1,034
  • 13
  • 27
1
vote
1 answer

About Creating an Alt with Hopac

When I use Hopac to create Alt with Alt. like always or once it would lead me to strange negative acknowledgement outcome. But if I use async {} to create Alt then everything works as expected. open Hopac open…
Anibal Yeh
  • 349
  • 1
  • 11
1
vote
1 answer

Does the >>= operator not take a function?

I'm working on a side project and I'm using Hopac for the first time. I ran into an odd (to me) compilation issue that I haven't been able to grok. I suspect that I'm the problem here, and not Hopac. The program is supposed to be a simple console…
Ben Collins
  • 20,538
  • 18
  • 127
  • 187
1
vote
1 answer

Hopac timeOutMillis does not work as expected

I recently started playing with Hopac and think that this is just awesome. Here is, however a problem that I cannot wrap my head around. Below is the code snippet: let rnd = new Random() let logger (msg:string) = let c = Ch() let…
Maxim Podkolzin
  • 378
  • 2
  • 10
0
votes
1 answer

How to make the Promise lazy?

open System open System.Threading open Hopac open Hopac.Infixes let hello what = job { for i=1 to 3 do do! timeOut (TimeSpan.FromSeconds 1.0) do printfn "%s" what } run <| job { let! j1 = Promise.start (hello "Hello, from a job!") …
Marko Grdinić
  • 3,798
  • 3
  • 18
  • 21