Skip to content

Commit 1b915ab

Browse files
committed
refactor(simulation): migrate Chan modules into Chan hierarchy
1 parent 77d8016 commit 1b915ab

32 files changed

+62
-53
lines changed

simulation/ouroboros-leios-sim.cabal

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ library
4242

4343
exposed-modules:
4444
Chan
45-
ChanDriver
46-
ChanMux
47-
ChanTCP
45+
Chan.Core
46+
Chan.Driver
47+
Chan.Mux
48+
Chan.TCP
4849
Diffusion
4950
ExamplesLayout
5051
ExamplesRelay

simulation/src/Chan.hs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
module Chan where
1+
module Chan (
2+
module Chan.Core,
3+
module Chan.Driver,
4+
module Chan.Mux,
5+
module Chan.TCP,
6+
) where
27

3-
data Chan m a = Chan
4-
{ readChan :: m a
5-
, writeChan :: a -> m ()
6-
}
8+
import Chan.Core
9+
import Chan.Driver
10+
import Chan.Mux
11+
import Chan.TCP

simulation/src/Chan/Core.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Chan.Core where
2+
3+
data Chan m a = Chan
4+
{ readChan :: m a
5+
, writeChan :: a -> m ()
6+
}

simulation/src/ChanDriver.hs renamed to simulation/src/Chan/Driver.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
{-# LANGUAGE UndecidableInstances #-}
1010
{-# OPTIONS_GHC -Wno-name-shadowing #-}
1111

12-
module ChanDriver where
12+
module Chan.Driver where
1313

14-
import Chan
15-
import ChanTCP
14+
import Chan.Core
15+
import Chan.TCP
1616
import Data.Type.Equality
1717
import Network.TypedProtocol (
1818
ActiveState,

simulation/src/ChanMux.hs renamed to simulation/src/Chan/Mux.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{-# LANGUAGE TypeApplications #-}
1010
{-# LANGUAGE TypeFamilies #-}
1111

12-
module ChanMux (
12+
module Chan.Mux (
1313
newMuxChan,
1414
Chan (..),
1515
ToFromMuxMsg (..),
@@ -20,8 +20,8 @@ module ChanMux (
2020
newConnectionBundleTCP,
2121
) where
2222

23-
import Chan
24-
import ChanTCP
23+
import Chan.Core
24+
import Chan.TCP
2525
import qualified Control.Category as Cat
2626
import Control.Concurrent.Class.MonadMVar (
2727
MonadMVar (MVar, newMVar, withMVar),

simulation/src/ChanTCP.hs renamed to simulation/src/Chan/TCP.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{-# LANGUAGE NamedFieldPuns #-}
33
{-# LANGUAGE ScopedTypeVariables #-}
44

5-
module ChanTCP (
5+
module Chan.TCP (
66
newConnectionTCP,
77
MessageSize (..),
88
Bytes,
@@ -11,7 +11,7 @@ module ChanTCP (
1111
TcpConnProps (..),
1212
) where
1313

14-
import Chan (Chan (..))
14+
import Chan.Core (Chan (..))
1515
import Control.Exception (assert)
1616
import Control.Monad (when)
1717
import Control.Monad.Class.MonadAsync (MonadAsync (async))

simulation/src/LeiosProtocol/Common.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module LeiosProtocol.Common (
3939
)
4040
where
4141

42-
import ChanTCP
42+
import Chan.TCP
4343
import Control.Exception (assert)
4444
import Control.Monad (guard)
4545
import Data.Aeson

simulation/src/LeiosProtocol/Relay.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
module LeiosProtocol.Relay where
2626

2727
import Chan
28-
import ChanDriver (ProtocolMessage, chanDriver)
28+
import Chan.Driver (ProtocolMessage, chanDriver)
2929
import Control.DeepSeq (NFData)
3030
import Control.Exception (Exception, assert, throw)
3131
import Control.Monad (forM_, join, unless, void, when)

simulation/src/LeiosProtocol/Short/Node.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
module LeiosProtocol.Short.Node where
1515

16-
import ChanMux
16+
import Chan.Mux
1717
import Control.Category ((>>>))
1818
import Control.Concurrent.Class.MonadMVar
1919
import Control.Concurrent.Class.MonadSTM.TSem

simulation/src/LeiosProtocol/Short/Sim.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
module LeiosProtocol.Short.Sim where
1414

15-
import ChanDriver
16-
import ChanMux
17-
import ChanTCP
15+
import Chan.Driver
16+
import Chan.Mux
17+
import Chan.TCP
1818
import Control.Exception (assert)
1919
import Control.Monad (forever)
2020
import Control.Monad.Class.MonadFork (MonadFork (forkIO))

0 commit comments

Comments
 (0)