Just to say there is similar functionality in Marlow's async library: http://hackage.haskell.org/package/async-2.0.1.5/docs/Control-Concurrent-Asy... http://hackage.haskell.org/package/async-2.0.1.5/docs/Control-Concurrent-Asy... Might overkill for your issue, but I thought it was worth mentioning it. On 6 May 2014 12:48, Corentin Dupont <corentin.dupont@gmail.com> wrote:
Great, I didn't know unamb! Specially the function "race" included:
race :: IO<http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/System-IO.html#t:IO>a -> IO<http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/System-IO.html#t:IO>a -> IO<http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/System-IO.html#t:IO>a Race two actions against each other in separate threads, and pick whichever finishes first. See also amb<http://hackage.haskell.org/package/unamb-0.2.5/docs/Data-Unamb.html#v:amb>.
Could it be used to build a watchdog? Simply by providing one of the two arguments as an action that waits and then gives a default value.
On Tue, May 6, 2014 at 12:24 PM, Erik Hesselink <hesselink@gmail.com>wrote:
On Tue, May 6, 2014 at 11:38 AM, Chris Warburton <chriswarbo@googlemail.com> wrote:
Job Vranish <job.vranish@gmail.com> writes:
I've often found myself wanting a function like this. It would make certain kinds of knot-tying/cycle detection _much_ easier.
Is there any reason why this function can't/shouldn't exist?
This makes me think of the more widely-known 'parallel OR' operator, which evaluates its arguments in parallel and returns whichever finishes evaluating first.
This operator cannot be implemented in Lambda Calculus, but it can in Haskell (via threads). Unfortunately Googling for 'haskell "parallel or"' brings up sentence fragments ('...parallel or concurrent...') rather than a parallel or implementation.
Perhaps you are looking for 'unamb' [0]?
Erik
[0] http://hackage.haskell.org/package/unamb _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- *Alois Cochard* http://aloiscochard.blogspot.com http://twitter.com/aloiscochard http://github.com/aloiscochard