import Math.NumberTheory.Primes (factorise)
import System.Timeout (timeout)
import Control.Monad (liftM)
type RetType = [(Integer, Int)] -- factorise's return type
-- proposed function
timedFact :: Integer -> Integer -> Either RetType Integer
timedFact u n = ?
Trying to understand how to write a wrapper function for factorise which times out after u usec. If it succeeds it returns RetType
otherwise it returns Integer
(what was passed in)
I'm kind of new to Haskell. I understand a timeout requires working in the IO
Monad but I'm having trouble pulling back the appropriate result. (Note: I'm not married to Either
. Maybe RetType
would be fine, too).
Thanks for any help