{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -Wall #-}
module Control.Process.Pid
( Pid,
GetPid (..),
HasPid (..),
ReviewPid (..),
AsPid (..),
)
where
import Control.Category (id, (.))
import Control.Lens (Getter, Lens', Prism', Review, iso, unto)
import Data.Int (Int32)
import System.Posix.Types (CPid (CPid))
import System.Process (Pid)
class GetPid a where
viewPid ::
Getter a Pid
{-# INLINE viewPidInt32 #-}
viewPidInt32 ::
Getter a Int32
viewPidInt32 =
(Pid -> f Pid) -> a -> f a
forall a. GetPid a => Getter a Pid
Getter a Pid
viewPid
((Pid -> f Pid) -> a -> f a)
-> ((Int32 -> f Int32) -> Pid -> f Pid)
-> (Int32 -> f Int32)
-> a
-> f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Pid -> Int32) -> (Int32 -> Pid) -> Iso Pid Pid Int32 Int32
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
(\(CPid Int32
x) -> Int32
x)
Int32 -> Pid
CPid
instance GetPid Pid where
viewPid :: Getter Pid Pid
viewPid = (Pid -> f Pid) -> Pid -> f Pid
forall a. a -> a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
{-# INLINE viewPid #-}
class (GetPid a) => HasPid a where
pid ::
Lens' a Pid
{-# INLINE pidInt32 #-}
pidInt32 ::
Lens' a Int32
pidInt32 =
(Pid -> f Pid) -> a -> f a
forall a. HasPid a => Lens' a Pid
Lens' a Pid
pid
((Pid -> f Pid) -> a -> f a)
-> ((Int32 -> f Int32) -> Pid -> f Pid)
-> (Int32 -> f Int32)
-> a
-> f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Pid -> Int32) -> (Int32 -> Pid) -> Iso Pid Pid Int32 Int32
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
(\(CPid Int32
x) -> Int32
x)
Int32 -> Pid
CPid
instance HasPid Pid where
pid :: Lens' Pid Pid
pid =
(Pid -> f Pid) -> Pid -> f Pid
forall a. a -> a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
class ReviewPid a where
reviewPid ::
Review a Pid
{-# INLINE reviewPidInt32 #-}
reviewPidInt32 ::
Review a Int32
reviewPidInt32 =
Optic' p f a Pid
forall a. ReviewPid a => Review a Pid
Review a Pid
reviewPid
Optic' p f a Pid
-> (p Int32 (f Int32) -> p Pid (f Pid))
-> p Int32 (f Int32)
-> p a (f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Pid -> Int32) -> (Int32 -> Pid) -> Iso Pid Pid Int32 Int32
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
(\(CPid Int32
x) -> Int32
x)
Int32 -> Pid
CPid
instance ReviewPid Pid where
reviewPid :: Review Pid Pid
reviewPid = (Pid -> Pid) -> Optic p f Pid Pid Pid Pid
forall (p :: * -> * -> *) (f :: * -> *) b t s a.
(Profunctor p, Bifunctor p, Functor f) =>
(b -> t) -> Optic p f s t a b
unto Pid -> Pid
forall a. a -> a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
{-# INLINE reviewPid #-}
class (ReviewPid a) => AsPid a where
_Pid ::
Prism' a Pid
{-# INLINE _PidInt32 #-}
_PidInt32 ::
Prism' a Int32
_PidInt32 =
p Pid (f Pid) -> p a (f a)
forall a. AsPid a => Prism' a Pid
Prism' a Pid
_Pid
(p Pid (f Pid) -> p a (f a))
-> (p Int32 (f Int32) -> p Pid (f Pid))
-> p Int32 (f Int32)
-> p a (f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Pid -> Int32) -> (Int32 -> Pid) -> Iso Pid Pid Int32 Int32
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
(\(CPid Int32
x) -> Int32
x)
Int32 -> Pid
CPid
instance AsPid Pid where
_Pid :: Prism' Pid Pid
_Pid =
p Pid (f Pid) -> p Pid (f Pid)
forall a. a -> a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id