Skip to content

Commit fc58e4a

Browse files
committed
stbx-core: Move Firing, Initial, Common submodules out of Statebox.Core.Types. #331
1 parent c5d8a5f commit fc58e4a

File tree

4 files changed

+70
-56
lines changed

4 files changed

+70
-56
lines changed
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module Statebox.Core.Common
2+
( HexStr
3+
, Message
4+
, TxId
5+
) where
6+
7+
-- | This tags an Array that is expected (but not guaranteed) to have exactly one element. (TODO: newtype.)
8+
type Singleton = NonEmpty Array
9+
10+
type TxId = String
11+
12+
type HexStr = String
13+
14+
-- | Some transaction data has a 'message' field, and they have this type.
15+
type Message = String
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module Statebox.Core.Firing
2+
( Firing
3+
, GluedTransitionIdRaw
4+
, GluedTransitionId(..)
5+
, Singleton
6+
) where
7+
8+
import Prelude (class Eq, class Show, show, (<>))
9+
import Data.Maybe (Maybe)
10+
import Data.Newtype (class Newtype)
11+
import Data.NonEmpty (NonEmpty)
12+
13+
import Statebox.Core.Net (TID)
14+
import Statebox.Core.Common (Message, TxId)
15+
16+
type Firing =
17+
{ message :: Maybe Message
18+
, execution :: Maybe TxId -- ^ The execution that this firing is a descendent of.
19+
, path :: Singleton GluedTransitionIdRaw -- ^ The net and transition to fire.
20+
}
21+
22+
-- TODO This should be the newtype GluedTransitionId.
23+
type GluedTransitionIdRaw = Int
24+
25+
--------------------------------------------------------------------------------
26+
27+
newtype GluedTransitionId = GluedTransitionId TID
28+
29+
derive instance newtypeGluedTransitionId :: Newtype GluedTransitionId _
30+
31+
derive instance eqGluedTransitionId :: Eq GluedTransitionId
32+
33+
instance showGluedTransitionId :: Show GluedTransitionId where
34+
show (GluedTransitionId i) = "(GluedTransitionId " <> show i <> ")"
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module Statebox.Core.Initial
2+
( Initial
3+
) where
4+
5+
import Statebox.Core.Common (Message)
6+
7+
-- | Initial (aka root or namespace or genesis) transaction data.
8+
type Initial =
9+
{ message :: Message
10+
}
+11-56
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,15 @@
11
module Statebox.Core.Types
2-
( module Statebox.Core.Wiring
3-
, module Statebox.Core.Net
2+
( module Statebox.Core.Net
43
, module Statebox.Core.Diagram
5-
, Firing
6-
, GluedTransitionIdRaw
7-
, GluedTransitionId(..)
8-
, HexStr
9-
, Initial(..)
10-
, Message
11-
, Singleton
12-
, TxId
4+
, module Statebox.Core.Wiring
5+
, module Statebox.Core.Firing
6+
, module Statebox.Core.Initial
7+
, module Statebox.Core.Common
138
) where
149

15-
import Prelude
16-
import Data.Maybe (Maybe)
17-
import Data.Newtype (class Newtype)
18-
import Data.NonEmpty (NonEmpty)
19-
20-
import Statebox.Core.Net (Net, PID, TID, unTID)
21-
import Statebox.Core.Diagram (Diagram)
22-
import Statebox.Core.Wiring (Wiring)
23-
24-
--------------------------------------------------------------------------------
25-
26-
type Initial =
27-
{ message :: Message
28-
}
29-
30-
-- | Some transaction types have a 'message' field, and they have this type.
31-
type Message = String
32-
33-
--------------------------------------------------------------------------------
34-
35-
type Firing =
36-
{ message :: Maybe Message
37-
, execution :: Maybe TxId -- ^ The execution that this firing is a descendent of.
38-
, path :: Singleton GluedTransitionIdRaw -- ^ The net and transition to fire.
39-
}
40-
41-
type TxId = String
42-
43-
type HexStr = String
44-
45-
-- | This tags an Array that is expected (but not guaranteed) to have exactly one element. (TODO: newtype.)
46-
type Singleton = NonEmpty Array
47-
48-
-- TODO This should be the newtype GluedTransitionId.
49-
type GluedTransitionIdRaw = Int
50-
51-
--------------------------------------------------------------------------------
52-
53-
newtype GluedTransitionId = GluedTransitionId TID
54-
55-
derive instance newtypeGluedTransitionId :: Newtype GluedTransitionId _
56-
57-
derive instance eqGluedTransitionId :: Eq GluedTransitionId
58-
59-
instance showGluedTransitionId :: Show GluedTransitionId where
60-
show (GluedTransitionId i) = "(GluedTransitionId " <> show i <> ")"
10+
import Statebox.Core.Net
11+
import Statebox.Core.Diagram
12+
import Statebox.Core.Wiring
13+
import Statebox.Core.Firing
14+
import Statebox.Core.Initial
15+
import Statebox.Core.Common

0 commit comments

Comments
 (0)