{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -Wall #-}

module Control.Process.GroupID
  ( GroupID,
    GetGroupID (..),
    HasGroupID (..),
    ReviewGroupID (..),
    AsGroupID (..),
  )
where

import Control.Category (id)
import Control.Lens (Getter, Lens', Prism', Review, unto)
import System.Process.Internals (GroupID)

-- $setup
-- >>> import Prelude
-- >>> import Control.Lens

-- | Type class for values that can be viewed as a @GroupID@.
--
-- >>> view getGroupID (42 :: GroupID)
-- 42
class GetGroupID a where
  getGroupID ::
    Getter a GroupID

-- |
--
-- >>> view getGroupID (42 :: GroupID)
-- 42
instance GetGroupID GroupID where
  getGroupID :: Getter GroupID GroupID
getGroupID = (GroupID -> f GroupID) -> GroupID -> f GroupID
forall a. a -> a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
  {-# INLINE getGroupID #-}

-- | Type class for values with a lens into a @GroupID@.
--
-- >>> view groupID (42 :: GroupID)
-- 42
class (GetGroupID a) => HasGroupID a where
  groupID ::
    Lens' a GroupID

-- |
--
-- >>> view groupID (42 :: GroupID)
-- 42
-- >>> set groupID 99 (42 :: GroupID)
-- 99
instance HasGroupID GroupID where
  groupID :: Lens' GroupID GroupID
groupID =
    (GroupID -> f GroupID) -> GroupID -> f GroupID
forall a. a -> a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id

-- | Type class for values that can be constructed from a @GroupID@.
--
-- >>> review reviewGroupID (42 :: GroupID) :: GroupID
-- 42
class ReviewGroupID a where
  reviewGroupID ::
    Review a GroupID

-- |
--
-- >>> review reviewGroupID (42 :: GroupID) :: GroupID
-- 42
instance ReviewGroupID GroupID where
  reviewGroupID :: Review GroupID GroupID
reviewGroupID = (GroupID -> GroupID) -> Optic p f GroupID GroupID GroupID GroupID
forall (p :: * -> * -> *) (f :: * -> *) b t s a.
(Profunctor p, Bifunctor p, Functor f) =>
(b -> t) -> Optic p f s t a b
unto GroupID -> GroupID
forall a. a -> a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
  {-# INLINE reviewGroupID #-}

-- | Type class for values with a prism into a @GroupID@.
--
-- >>> preview _GroupID (42 :: GroupID)
-- Just 42
class (ReviewGroupID a) => AsGroupID a where
  _GroupID ::
    Prism' a GroupID

-- |
--
-- >>> preview _GroupID (42 :: GroupID)
-- Just 42
-- >>> review _GroupID 42 :: GroupID
-- 42
instance AsGroupID GroupID where
  _GroupID :: Prism' GroupID GroupID
_GroupID =
    p GroupID (f GroupID) -> p GroupID (f GroupID)
forall a. a -> a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id