on master help sign in
Remove redundant stuff from Log.hs
commit3a988778f65b87d2e3ef97289df9bd97f93e717d authorHarendra Kumar <harendra.kumar@gmail.com> dateMon 26 Jun 2017, 18:27 (9 years ago) parentb2f67d3
1 file changed+4−42
src/Strands/Log.hs+4−42
src/Strands/Log.hs+4−42
@@ -1,20 +1,13 @@
11{-# LANGUAGE ConstraintKinds #-}
2−{-# LANGUAGE ExistentialQuantification #-}
3−{-# LANGUAGE ScopedTypeVariables #-}
42
53module Strands.Log
64 ( Loggable
7− , Replaying
85 , LogEntry (..)
6+ , Replaying
97 , Log (..)
10− , IDynamic (..)
11− , fromIDyn
12− , toIDyn
138 )
149where
1510
16−import Unsafe.Coerce (unsafeCoerce)
17−
1811------------------------------------------------------------------------------
1912-- Log types
2013------------------------------------------------------------------------------
@@ -22,42 +15,11 @@ import Unsafe.Coerce (unsafeCoerce)
2215-- | Constraint type synonym for a value that can be logged.
2316type Loggable a = (Show a, Read a)
2417
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−
5518data LogEntry =
56− 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
19+ Executing -- we are inside this computation, not yet done
20+ | Maybe String -- computation is done and we have the result to replay
5921 deriving (Read, Show)
6022
6123type Replaying = Bool
6224
63−data Log = Log Replaying [LogEntry] deriving (Show)
25+data Log = Log Replaying [LogEntry] deriving (Read, Show)