connectCAS :: String -> IO (Handle, Handle, Handle, ProcessHandle)
connectCAS reducecmd = do
    putStrLn "succeeded"
    (inpt, out, errh, pid) <- runInteractiveCommand $ reducecmd ++ " -w"
    hSetBuffering out NoBuffering
    hSetBuffering inpt LineBuffering
    hPutStrLn inpt "off nat;"
    hPutStrLn inpt "load redlog;"
    hPutStrLn inpt "rlset reals;"
    -- read 7 lines
    replicateM_ 7 $ hGetLine out
    putStrLn "done"
    return (inpt, out, errh, pid)

-- | closes the connection to the CAS
connectCAS :: String -> IO (Handle, Handle, Handle, ProcessHandle)
connectCAS reducecmd = do
    putStrLn "succeeded"
    (inpt, out, errh, pid) <- runInteractiveCommand $ reducecmd ++ " -w"
    hSetBuffering out NoBuffering
    hSetBuffering inpt LineBuffering
    hPutStrLn inpt "off nat;"
    hPutStrLn inpt "load redlog;"
    hPutStrLn inpt "rlset reals;"
    -- read 7 lines
    replicateM_ 7 $ hGetLine out
    putStrLn "done"
    return (inpt, out, errh, pid)

-- | closes the connection to the CAS
connectCAS reducecmd = do
    putStrLn "succeeded"
    (inpt, out, errh, pid) <- runInteractiveCommand $ reducecmd ++ " -w"
    hSetBuffering out NoBuffering
    hSetBuffering inpt LineBuffering
    hPutStrLn inpt "off nat;"
    hPutStrLn inpt "load redlog;"
    hPutStrLn inpt "rlset reals;"
    -- read 7 lines
    replicateM_ 7 $ hGetLine out
    putStrLn "done"
    return (inpt, out, errh, pid)

-- | closes the connection to the CAS