|
1 | 1 | module Statebox.Core.Transition where |
2 | 2 |
|
3 | | -import Prelude |
4 | | -import Data.Array ((:)) |
5 | | -import Data.FoldableWithIndex (foldrWithIndex) |
6 | | -import Data.Map (Map) |
7 | | - |
8 | | -import Data.ArrayMultiset as ArrayMultiset |
9 | | -import Data.ArrayMultiset (ArrayMultiset) |
10 | 3 | import Statebox.Core.Execution (Path) |
11 | 4 | import Statebox.Core.Types (PID, TID) |
12 | | - |
13 | | --------------------------------------------------------------------------------- |
14 | | - |
15 | | --- | TODO Duplicated from `Data.Petrinet.Representation.Dict` in #328. |
16 | | -type TransitionF p tok = |
17 | | - { pre :: Array (PlaceMarkingF p tok) |
18 | | - , post :: Array (PlaceMarkingF p tok) |
19 | | - } |
20 | | - |
21 | | --- | TODO Duplicated from `Data.Petrinet.Representation.Dict` in #328. |
22 | | -type PlaceMarkingF p tok = |
23 | | - { place :: p |
24 | | - , tokens :: tok |
25 | | - } |
26 | | - |
27 | | --- | TODO Duplicated from `Data.Petrinet.Representation.Dict` in #328. |
28 | | -type Tokens = Int |
29 | | - |
30 | | --------------------------------------------------------------------------------- |
31 | | - |
32 | | -buildTransitionMarking :: ∀ a. Ord a => ArrayMultiset a -> ArrayMultiset a -> TransitionF a Tokens |
33 | | -buildTransitionMarking pre post = |
34 | | - { pre: buildPlaceMarkings pre |
35 | | - , post: buildPlaceMarkings post |
36 | | - } |
37 | | - |
38 | | -buildPlaceMarkings :: ∀ a. Ord a => ArrayMultiset a -> Array (PlaceMarkingF a Tokens) |
39 | | -buildPlaceMarkings netMarking = |
40 | | - foldrWithIndex (\place tokens -> (:) { place, tokens }) [] netMarkingDict |
41 | | - where |
42 | | - netMarkingDict :: Map a Tokens |
43 | | - netMarkingDict = ArrayMultiset.countMap netMarking |
44 | | - |
45 | | --------------------------------------------------------------------------------- |
| 5 | +import Statebox.Core.Marking (Tokens, TransitionF) |
46 | 6 |
|
47 | 7 | type Transition = |
48 | 8 | { path :: Path |
|
0 commit comments