Skip to content

Commit 9d9276c

Browse files
committed
remove ambiguity b/t Supervisor/Child/Starter PIDs
- use SupervisorPid, ChildPid, StarterPid type aliases rather than ambiguous ProcessId - rename uses of `pid` as an expr name to `childPid` or `sup` Ideally all internal bits of Supervisor would use phantom types to make this a type level rather than name based distinction. This is a first step towards that goal.
1 parent 4b8ae09 commit 9d9276c

File tree

1 file changed

+12
-7
lines changed
  • src/Control/Distributed/Process/Platform/Supervisor

1 file changed

+12
-7
lines changed

src/Control/Distributed/Process/Platform/Supervisor/Types.hs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ module Control.Distributed.Process.Platform.Supervisor.Types
2727
, Child
2828
, StaticLabel
2929
, SupervisorPid
30+
, ChildPid
31+
, StarterPid
3032
-- * Limits and Defaults
3133
, MaxRestarts(..)
3234
, maxRestarts
@@ -64,6 +66,10 @@ import Control.Distributed.Process.Platform.Time
6466
import Control.Distributed.Process.Platform.Internal.Primitives hiding (monitor)
6567
import Control.Exception (Exception)
6668

69+
-- aliases for api documentation purposes
70+
type SupervisorPid = ProcessId
71+
type ChildPid = ProcessId
72+
type StarterPid = ProcessId
6773

6874
newtype MaxRestarts = MaxR { maxNumberOfRestarts :: Int }
6975
deriving (Typeable, Generic, Show)
@@ -184,9 +190,9 @@ type ChildKey = String
184190

185191
-- | A reference to a (possibly running) child.
186192
data ChildRef =
187-
ChildRunning !ProcessId -- ^ a reference to the (currently running) child
188-
| ChildRunningExtra !ProcessId !Message -- ^ also a currently running child, with /extra/ child info
189-
| ChildRestarting !ProcessId -- ^ a reference to the /old/ (previous) child (now restarting)
193+
ChildRunning !ChildPid -- ^ a reference to the (currently running) child
194+
| ChildRunningExtra !ChildPid !Message -- ^ also a currently running child, with /extra/ child info
195+
| ChildRestarting !ChildPid -- ^ a reference to the /old/ (previous) child (now restarting)
190196
| ChildStopped -- ^ indicates the child is not currently running
191197
| ChildStartIgnored -- ^ a non-temporary child exited with 'ChildInitIgnore'
192198
deriving (Typeable, Generic, Show)
@@ -250,7 +256,7 @@ instance NFData ChildTerminationPolicy where
250256
data RegisteredName =
251257
LocalName !String
252258
| GlobalName !String
253-
| CustomRegister !(Closure (ProcessId -> Process ()))
259+
| CustomRegister !(Closure (ChildPid -> Process ()))
254260
deriving (Typeable, Generic)
255261
instance Binary RegisteredName where
256262
instance NFData RegisteredName where
@@ -262,8 +268,8 @@ instance Show RegisteredName where
262268

263269
data ChildStart =
264270
RunClosure !(Closure (Process ()))
265-
| CreateHandle !(Closure (SupervisorPid -> Process (ProcessId, Message)))
266-
| StarterProcess !ProcessId
271+
| CreateHandle !(Closure (SupervisorPid -> Process (ChildPid, Message)))
272+
| StarterProcess !StarterPid
267273
deriving (Typeable, Generic, Show)
268274
instance Binary ChildStart where
269275
instance NFData ChildStart where
@@ -327,7 +333,6 @@ instance Binary DeleteChildResult where
327333
instance NFData DeleteChildResult where
328334

329335
type Child = (ChildRef, ChildSpec)
330-
type SupervisorPid = ProcessId
331336

332337
-- exported result types of internal APIs
333338

0 commit comments

Comments
 (0)