statebox / cql

CQL: Categorical Query Language implementation in Haskell
GNU Affero General Public License v3.0
163 stars 15 forks source link

refactor #107

Closed wisnesky closed 5 years ago

wisnesky commented 5 years ago

I looked for a timeout :: Int -> a -> a function but couldn’t find one. You’re welcome to change this if you can. Eventually, evaluation of expressions will move to the IO monad due to e.g. SQL database access or need for high-performance in-memeory data structures.

On Oct 24, 2018, at 7:56 AM, Erik Post notifications@github.com wrote:

@epost commented on this pull request.

In src/Language/AQL.hs:

@@ -22,6 +22,16 @@ import Data.Void import Data.Typeable import Language.Options import Control.Arrow (left) +import System.Timeout +import System.IO.Unsafe + +timeout' :: Int -> x -> Err x +timeout' ms c = case c' of

  • Nothing -> Left $ "Timeout after " ++ (show s) ++ " seconds."
  • Just x' -> pure x'
  • where
  • c' = unsafePerformIO $ timeout s (return c)

Can we refactor this to use safe IO at some point?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

epost commented 5 years ago

@wisnesky Yeah, doing I/O in IO is what I meant; but in that case we'll get to that. (That said, generally speaking, it may (?) be helpful to start doing that sooner rather than later.) Also, it sounds like there may be evaluations that must be in IO, and perhaps evaluations that wouldn't need to? As we move into IO it'd be nice to be as 'pure' as possible here.