Search code examples
haskellconcurrencyparallel-processingfuturealice

Futures in Haskell


Does Haskell have an equivalent of Alice's ability to bind a variable to a future?

val a = spawn foo;

where foo is some function.

I know Haskell supports channels and threads; I'm hoping for syntax as natural as Alice's to bind a value to a future and spawn a thread to calculate it without having to deal with the details.


Solution

  • You can use par from Control.Parallel as in

    a `par` f a b c
    where
      a = foo
    

    This is a hint to the runtime that a could be evaluated in another thread.