haskell-cafe@haskell.org
[Top] [All Lists]

[Haskell-cafe] nondet function

Subject: [Haskell-cafe] nondet function
From: Ashley Yakeley
Date: Sat, 09 Sep 2006 21:21:33 -0700
Is it possible to write nondet?

  nondet :: a -> a -> a

  nondet _|_ _|_ = _|_
  nondet _|_ q = q
  nondet p _|_ = p
  nondet p q = p or q

nondet evaluates its arguments in parallel, and returns the first one of 
them to evaluate. It's thus a bit different from the "par" of GPH. This 
isn't referentially transparent, of course, but maybe it could be 
written in the IO monad:

  nondet p q = unsafePerformIO (getnondet p q)

  getnondet :: a -> a -> IO a

-- 
Ashley Yakeley, Seattle WA

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>