{-# options_haddock prune #-}

-- |Description: ProcessInput Interpreters, Internal
module Polysemy.Process.Interpreter.ProcessInput where

import Polysemy.Process.Effect.ProcessInput (ProcessInput (Encode))

-- |Interpret 'ProcessInput' by passing 'ByteString' through.
interpretProcessInputId :: InterpreterFor (ProcessInput ByteString) r
interpretProcessInputId :: forall (r :: [Effect]). InterpreterFor (ProcessInput ByteString) r
interpretProcessInputId =
  (forall (rInitial :: [Effect]) x.
 ProcessInput ByteString (Sem rInitial) x -> Sem r x)
-> Sem (ProcessInput ByteString : r) a -> Sem r a
forall (e :: Effect) (r :: [Effect]) a.
FirstOrder e "interpret" =>
(forall (rInitial :: [Effect]) x. e (Sem rInitial) x -> Sem r x)
-> Sem (e : r) a -> Sem r a
interpret \case
    Encode ByteString
value ->
      ByteString -> Sem r ByteString
forall (f :: * -> *) a. Applicative f => a -> f a
pure ByteString
value
{-# inline interpretProcessInputId #-}

-- |Interpret 'ProcessInput' by UTF-8-encoding 'Text'.
interpretProcessInputText :: InterpreterFor (ProcessInput Text) r
interpretProcessInputText :: forall (r :: [Effect]). InterpreterFor (ProcessInput Text) r
interpretProcessInputText =
  (forall (rInitial :: [Effect]) x.
 ProcessInput Text (Sem rInitial) x -> Sem r x)
-> Sem (ProcessInput Text : r) a -> Sem r a
forall (e :: Effect) (r :: [Effect]) a.
FirstOrder e "interpret" =>
(forall (rInitial :: [Effect]) x. e (Sem rInitial) x -> Sem r x)
-> Sem (e : r) a -> Sem r a
interpret \case
    Encode Text
value ->
      x -> Sem r x
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text -> x
forall a b. ConvertUtf8 a b => a -> b
encodeUtf8 Text
value)
{-# inline interpretProcessInputText #-}