{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeFamilies #-}

module Options.Harg.Sources.NoSource
  ( NoSource,
    noSources,
  )
where

import qualified Barbies as B
import Data.Kind (Type)
import GHC.Generics (Generic)
import Options.Harg.Sources.Types

-- | Throwaway type whose 'GetSource' instance returns no value.
data NoSource (f :: Type -> Type) = NoSource
  deriving ((forall x. NoSource f -> Rep (NoSource f) x)
-> (forall x. Rep (NoSource f) x -> NoSource f)
-> Generic (NoSource f)
forall x. Rep (NoSource f) x -> NoSource f
forall x. NoSource f -> Rep (NoSource f) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (f :: * -> *) x. Rep (NoSource f) x -> NoSource f
forall (f :: * -> *) x. NoSource f -> Rep (NoSource f) x
$cto :: forall (f :: * -> *) x. Rep (NoSource f) x -> NoSource f
$cfrom :: forall (f :: * -> *) x. NoSource f -> Rep (NoSource f) x
Generic, (forall (f :: * -> *) (g :: * -> *).
 (forall a. f a -> g a) -> NoSource f -> NoSource g)
-> FunctorB NoSource
forall k (b :: (k -> *) -> *).
(forall (f :: k -> *) (g :: k -> *).
 (forall (a :: k). f a -> g a) -> b f -> b g)
-> FunctorB b
forall (f :: * -> *) (g :: * -> *).
(forall a. f a -> g a) -> NoSource f -> NoSource g
bmap :: (forall a. f a -> g a) -> NoSource f -> NoSource g
$cbmap :: forall (f :: * -> *) (g :: * -> *).
(forall a. f a -> g a) -> NoSource f -> NoSource g
B.FunctorB, FunctorB NoSource
FunctorB NoSource =>
(forall (e :: * -> *) (f :: * -> *) (g :: * -> *).
 Applicative e =>
 (forall a. f a -> e (g a)) -> NoSource f -> e (NoSource g))
-> TraversableB NoSource
forall k (b :: (k -> *) -> *).
FunctorB b =>
(forall (e :: * -> *) (f :: k -> *) (g :: k -> *).
 Applicative e =>
 (forall (a :: k). f a -> e (g a)) -> b f -> e (b g))
-> TraversableB b
forall (e :: * -> *) (f :: * -> *) (g :: * -> *).
Applicative e =>
(forall a. f a -> e (g a)) -> NoSource f -> e (NoSource g)
btraverse :: (forall a. f a -> e (g a)) -> NoSource f -> e (NoSource g)
$cbtraverse :: forall (e :: * -> *) (f :: * -> *) (g :: * -> *).
Applicative e =>
(forall a. f a -> e (g a)) -> NoSource f -> e (NoSource g)
$cp1TraversableB :: FunctorB NoSource
B.TraversableB, FunctorB NoSource
FunctorB NoSource =>
(forall (f :: * -> *). (forall a. f a) -> NoSource f)
-> (forall (f :: * -> *) (g :: * -> *).
    NoSource f -> NoSource g -> NoSource (Product f g))
-> ApplicativeB NoSource
forall k (b :: (k -> *) -> *).
FunctorB b =>
(forall (f :: k -> *). (forall (a :: k). f a) -> b f)
-> (forall (f :: k -> *) (g :: k -> *).
    b f -> b g -> b (Product f g))
-> ApplicativeB b
forall (f :: * -> *). (forall a. f a) -> NoSource f
forall (f :: * -> *) (g :: * -> *).
NoSource f -> NoSource g -> NoSource (Product f g)
bprod :: NoSource f -> NoSource g -> NoSource (Product f g)
$cbprod :: forall (f :: * -> *) (g :: * -> *).
NoSource f -> NoSource g -> NoSource (Product f g)
bpure :: (forall a. f a) -> NoSource f
$cbpure :: forall (f :: * -> *). (forall a. f a) -> NoSource f
$cp1ApplicativeB :: FunctorB NoSource
B.ApplicativeB)

instance GetSource NoSource f where
  type SourceVal NoSource = ()
  getSource :: HargCtx -> NoSource f -> IO (SourceVal NoSource)
getSource _ctx :: HargCtx
_ctx _ = () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()

-- | Shorthand for writing 'NoSource'.
noSources :: NoSource f
noSources :: NoSource f
noSources = NoSource f
forall (f :: * -> *). NoSource f
NoSource