-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcess.hs
More file actions
33 lines (31 loc) · 1.11 KB
/
Process.hs
File metadata and controls
33 lines (31 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module Process(
module Process,
module Process.Language,
module Process.Combinators,
module Process.Eval,
module Process.Simplify,
module Process.Input) where
import Process.Language(Process, Step, Expr, PrimitiveKind(..), Var(..), vars)
import Process.Combinators
import Process.Eval(Value(..), Env, Valued(..), Result(..), simulate)
import qualified Process.Eval
import Process.Simplify(lower, simplify)
import Process.Input(Types, Duration, Time(..), Type(..))
import Process.Pretty()
import qualified Plot
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
plot :: FilePath -> Double -> [Env] -> Process -> IO ()
plot name delta envs p =
Plot.plot name maxBound
[[(x, timed (map (value . Map.findWithDefault undefined (Global x)) envs))]
| Global x <- Set.toList vs ]
where
-- Idea: by passing the original (not lowered) process to plot,
-- we can avoid drawing graphs of variables introduced during lowering
vs = vars p
times = [0, delta..]
timed xs = unzip (zip times xs)
value (BoolValue False) = 0
value (BoolValue True) = 1
value (DoubleValue x) = x