module Mueval.Parallel (runMueval) where

import Control.Monad (void)

import Mueval.ArgsParse (Options (modules, noImports, timeLimit))
import Mueval.Interpreter (interpreterSession)
import System.Timeout (timeout)

runMueval :: Options -> IO ()
runMueval :: Options -> IO ()
runMueval Options
opts =
    let time :: Int
time = Options -> Int
timeLimit Options
opts Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
1000000
        checkImport :: Options -> Options
checkImport Options
x = if Options -> Bool
noImports Options
x then Options
x{modules = Nothing} else Options
x
     in IO (Maybe ()) -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO (Maybe ()) -> IO ()) -> IO (Maybe ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ Int -> IO () -> IO (Maybe ())
forall a. Int -> IO a -> IO (Maybe a)
timeout Int
time (IO () -> IO (Maybe ())) -> IO () -> IO (Maybe ())
forall a b. (a -> b) -> a -> b
$ Options -> IO ()
interpreterSession (Options -> Options
checkImport Options
opts)