-- |Interpreters for @'Reader' ('PluginConfig' c)@
module Ribosome.Interpreter.PluginName where

import Ribosome.Data.PluginConfig (PluginConfig (PluginConfig, name))
import Ribosome.Data.PluginName (PluginName)

-- |Interpret @'Reader' 'PluginName'@ by extracting the name from the plugin config provided by another @'Reader'
-- 'PluginConfig'@.
--
-- This interpreter is used by the main function machinery.
interpretPluginName ::
  Member (Reader (PluginConfig c)) r =>
  InterpreterFor (Reader PluginName) r
interpretPluginName :: forall c (r :: EffectRow).
Member (Reader (PluginConfig c)) r =>
InterpreterFor (Reader PluginName) r
interpretPluginName Sem (Reader PluginName : r) a
sem =
  Sem r (PluginConfig c)
forall i (r :: EffectRow). Member (Reader i) r => Sem r i
ask Sem r (PluginConfig c) -> (PluginConfig c -> Sem r a) -> Sem r a
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ PluginConfig {PluginName
name :: PluginName
$sel:name:PluginConfig :: forall c. PluginConfig c -> PluginName
name} ->
    PluginName -> Sem (Reader PluginName : r) a -> Sem r a
forall i (r :: EffectRow) a. i -> Sem (Reader i : r) a -> Sem r a
runReader PluginName
name Sem (Reader PluginName : r) a
sem