IODriver.hs (902B)
1 -- Version dispatch only. Historical envelopes remain inspectable data, but the 2 -- current host executes protocol 2 exclusively. No probing, retry or grants. 3 module IODriver (checkIOSentinel, runIO) where 4 5 import Runtime (T(..), ofString) 6 import qualified IO.Driver as HostIO 7 8 checkIOSentinel :: T -> Either String (Integer, T) 9 checkIOSentinel tree = case tree of 10 Fork sentinel (Fork version action) 11 | sentinel /= ofString "tricuIO" -> Left "sentinel mismatch (expected canonical tricuIO)" 12 | otherwise -> case HostIO.canonicalNat 16 version of 13 Just v -> Right (v, action) 14 Nothing -> Left "invalid IO envelope version" 15 _ -> Left "root is not an IO sentinel pair" 16 17 runIO :: T -> IO (Either String T) 18 runIO tree = case checkIOSentinel tree of 19 Left problem -> pure (Left problem) 20 Right (2, action) -> HostIO.run action 21 Right _ -> pure (Left "Unsupported tricuIO version")