on master help sign in
Remove redundant stuff from Log.hs
3a98877Harendra Kumar
src/Strands/Log.hs+4−42
@@ -1,20 +1,13 @@
1{-# LANGUAGE ConstraintKinds #-}
1{-# LANGUAGE ConstraintKinds #-}
2−{-# LANGUAGE ExistentialQuantification #-}
3−{-# LANGUAGE ScopedTypeVariables #-}
4
2
5module Strands.Log
3module Strands.Log
6 ( Loggable
4 ( Loggable
7− , Replaying
8 , LogEntry (..)
5 , LogEntry (..)
6+ , Replaying
9 , Log (..)
7 , Log (..)
10− , IDynamic (..)
11− , fromIDyn
12− , toIDyn
13 )
8 )
14where
9where
15
10
16−import Unsafe.Coerce (unsafeCoerce)
17−
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)
24
17
25−------------------------------------------------------------------------------
26−-- Serialization
27−------------------------------------------------------------------------------
28−
29−-- | Dynamic serializable data for logging.
30−data IDynamic =
31− IDyns String
32− | forall a. Loggable a => IDynamic a
33−
34−instance Show IDynamic where
35− show (IDynamic x) = show (show x)
36− show (IDyns s) = show s
37−
38−instance Read IDynamic where
39− readsPrec _ str = map (\(x,s) -> (IDyns x,s)) $ readsPrec 0 str
40−
41−fromIDyn :: Loggable a => IDynamic -> a
42−fromIDyn (IDynamic x) = r
43− where r = unsafeCoerce x
44−
45−fromIDyn (IDyns s) = r `seq` r
46− where r = read s
47−
48−toIDyn :: Loggable a => a -> IDynamic
49−toIDyn x = IDynamic x
50−
51−------------------------------------------------------------------------------
52−-- Log
53−------------------------------------------------------------------------------
54−
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)
60
22
61type Replaying = Bool
23type Replaying = Bool
62
24
63−data Log = Log Replaying [LogEntry] deriving (Show)
25+data Log = Log Replaying [LogEntry] deriving (Read, Show)