Permalink
Browse files

Events should contain the Values they come from, not be printed to text.

Text representation will generally be unique, but may cause problems in a
multiple module system. Further, the cost of converting to the text is likely
to be greater than the cost of compiling it to an Int using a hash table
later on.
  • Loading branch information...
1 parent ac59a6e commit ecef50ced6eee818fb9f9356aba753cb5d8323a9 @tomgr committed Apr 23, 2012
Showing with 6 additions and 9 deletions.
  1. +6 −7 src/CSPM/Compiler/Events.hs
  2. +0 −2 src/CSPM/Evaluator/Values.hs
@@ -1,14 +1,16 @@
{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}
module CSPM.Compiler.Events (
- Event(..), newUserEvent,
+ Event(..),
EventSet, fromList,
) where
import Data.Foldable as F
import Data.Hashable
import qualified Data.Sequence as Sq
-import qualified Data.Text as T
+
+import {-# SOURCE #-} CSPM.Evaluator.Values
import Util.PrettyPrint
+import qualified Util.TextPrettyPrint as T
-- | Events, as represented in the LTS.
data Event =
@@ -17,14 +19,11 @@ data Event =
-- | The internal event tick, representing termination.
| Tick
-- | Any event defined in a channel definition.
- | UserEvent T.Text
+ | UserEvent Value
deriving (Eq, Ord)
type EventSet = Sq.Seq Event
-newUserEvent :: String -> Event
-newUserEvent = UserEvent . T.pack
-
fromList :: [Event] -> EventSet
fromList = Sq.fromList
@@ -35,7 +34,7 @@ instance Hashable Event where
instance PrettyPrintable Event where
prettyPrint Tau = char 'τ'
prettyPrint Tick = char ''
- prettyPrint (UserEvent s) = text (T.unpack s)
+ prettyPrint (UserEvent v) = prettyPrint v
instance Show Event where
show ev = show (prettyPrint ev)
@@ -245,8 +245,6 @@ procId n vss pn = ProcName n vss pn
annonymousProcId :: [[Value]] -> Maybe ProcName -> ProcName
annonymousProcId vss pn = AnnonymousProcName vss pn
-instance T.FastPrettyPrintable Name where
- toBuilder (Name { nameOccurrence = OccName s }) = T.text s
instance T.FastPrettyPrintable Value where
toBuilder (VInt i) = T.integral i
toBuilder (VBool b) = if b then T.stext "true" else T.stext "false"

0 comments on commit ecef50c

Please sign in to comment.