{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -Wall #-}
module Control.Process.FD
( FD,
GetFD (..),
HasFD (..),
ReviewFD (..),
AsFD (..),
)
where
import Control.Category (id, (.))
import Control.Lens (Getter, Lens', Prism', Review, iso, unto)
import Data.Int (Int32)
import Foreign.C.Types (CInt (CInt))
import System.Posix.Internals (FD)
class GetFD a where
getFD ::
Getter a FD
{-# INLINE getFDInt32 #-}
getFDInt32 ::
Getter a Int32
getFDInt32 =
(FD -> f FD) -> a -> f a
forall a. GetFD a => Getter a FD
Getter a FD
getFD
((FD -> f FD) -> a -> f a)
-> ((Int32 -> f Int32) -> FD -> f FD)
-> (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
. (FD -> Int32) -> (Int32 -> FD) -> Iso FD FD Int32 Int32
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
(\(CInt Int32
x) -> Int32
x)
Int32 -> FD
CInt
instance GetFD FD where
getFD :: Getter FD FD
getFD = (FD -> f FD) -> FD -> f FD
forall a. a -> a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
{-# INLINE getFD #-}
class (GetFD a) => HasFD a where
fd ::
Lens' a FD
{-# INLINE fdInt32 #-}
fdInt32 ::
Lens' a Int32
fdInt32 =
(FD -> f FD) -> a -> f a
forall a. HasFD a => Lens' a FD
Lens' a FD
fd
((FD -> f FD) -> a -> f a)
-> ((Int32 -> f Int32) -> FD -> f FD)
-> (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
. (FD -> Int32) -> (Int32 -> FD) -> Iso FD FD Int32 Int32
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
(\(CInt Int32
x) -> Int32
x)
Int32 -> FD
CInt
instance HasFD FD where
fd :: Lens' FD FD
fd =
(FD -> f FD) -> FD -> f FD
forall a. a -> a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
class ReviewFD a where
reviewFD ::
Review a FD
{-# INLINE reviewFDInt32 #-}
reviewFDInt32 ::
Review a Int32
reviewFDInt32 =
Optic' p f a FD
forall a. ReviewFD a => Review a FD
Review a FD
reviewFD
Optic' p f a FD
-> (p Int32 (f Int32) -> p FD (f FD))
-> 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
. (FD -> Int32) -> (Int32 -> FD) -> Iso FD FD Int32 Int32
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
(\(CInt Int32
x) -> Int32
x)
Int32 -> FD
CInt
instance ReviewFD FD where
reviewFD :: Review FD FD
reviewFD = (FD -> FD) -> Optic p f FD FD FD FD
forall (p :: * -> * -> *) (f :: * -> *) b t s a.
(Profunctor p, Bifunctor p, Functor f) =>
(b -> t) -> Optic p f s t a b
unto FD -> FD
forall a. a -> a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
{-# INLINE reviewFD #-}
class (ReviewFD a) => AsFD a where
_FD ::
Prism' a FD
{-# INLINE _FDInt32 #-}
_FDInt32 ::
Prism' a Int32
_FDInt32 =
p FD (f FD) -> p a (f a)
forall a. AsFD a => Prism' a FD
Prism' a FD
_FD
(p FD (f FD) -> p a (f a))
-> (p Int32 (f Int32) -> p FD (f FD))
-> 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
. (FD -> Int32) -> (Int32 -> FD) -> Iso FD FD Int32 Int32
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
(\(CInt Int32
x) -> Int32
x)
Int32 -> FD
CInt
instance AsFD FD where
_FD :: Prism' FD FD
_FD =
p FD (f FD) -> p FD (f FD)
forall a. a -> a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id