[Haskell-cafe] wanted: Function to break circular data dependencies
Chris Wong
lambda.fairy at gmail.com
Tue May 6 23:08:46 UTC 2014
On Tue, May 6, 2014 at 11:48 PM, Corentin Dupont
<corentin.dupont at gmail.com> wrote:
> Great, I didn't know unamb! Specially the function "race" included:
>
> race :: IO a -> IO a -> IO a
> Race two actions against each other in separate threads, and pick whichever
> finishes first. See also 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.
If you simply want a timeout, then I'd suggest System.Timeout instead[1]
[1] http://hackage.haskell.org/package/base-4.7.0.0/docs/System-Timeout.html
>
> On Tue, May 6, 2014 at 12:24 PM, Erik Hesselink <hesselink at gmail.com> wrote:
>>
>> On Tue, May 6, 2014 at 11:38 AM, Chris Warburton
>> <chriswarbo at googlemail.com> wrote:
>> > Job Vranish <job.vranish at 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 at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list