@@ -1,20 +1,13 @@
1{-# LANGUAGE ConstraintKinds #-}
1{-# LANGUAGE ConstraintKinds #-}
2−{-# LANGUAGE ExistentialQuantification #-}
3−{-# LANGUAGE ScopedTypeVariables #-}
5module Strands.Log
3module Strands.Log
8 , LogEntry (..)
5 , LogEntry (..)
16−import Unsafe.Coerce (unsafeCoerce)
18------------------------------------------------------------------------------
11------------------------------------------------------------------------------
19-- Log types
12-- Log types
20------------------------------------------------------------------------------
13------------------------------------------------------------------------------
@@ -22,42 +15,11 @@ import Unsafe.Coerce (unsafeCoerce)
22-- | Constraint type synonym for a value that can be logged.
15-- | Constraint type synonym for a value that can be logged.
23type Loggable a = (Show a, Read a)
16type Loggable a = (Show a, Read a)
25−------------------------------------------------------------------------------
27−------------------------------------------------------------------------------
29−-- | Dynamic serializable data for logging.
32− | forall a. Loggable a => IDynamic a
34−instance Show IDynamic where
35− show (IDynamic x) = show (show x)
36− show (IDyns s) = show s
38−instance Read IDynamic where
39− readsPrec _ str = map (\(x,s) -> (IDyns x,s)) $ readsPrec 0 str
41−fromIDyn :: Loggable a => IDynamic -> a
42−fromIDyn (IDynamic x) = r
43− where r = unsafeCoerce x
45−fromIDyn (IDyns s) = r `seq` r
48−toIDyn :: Loggable a => a -> IDynamic
51−------------------------------------------------------------------------------
53−------------------------------------------------------------------------------
55data LogEntry =
18data LogEntry =
56− Executing -- we are inside this computation, not yet done
19+ Executing -- we are inside this computation, not yet done
57− | Waiting -- the computation is done and it returned mzero
58− | Result IDynamic -- computation is done and we have the result to replay
20+ | Maybe String -- computation is done and we have the result to replay
59 deriving (Read, Show)
21 deriving (Read, Show)
61type Replaying = Bool
23type Replaying = Bool
63−data Log = Log Replaying [LogEntry] deriving (Show)
25+data Log = Log Replaying [LogEntry] deriving (Read, Show)