module WikiMusic.SSR.Free.Logger
  ( logInfo,
    logError,
    logDebug,
    Logger (..),
  )
where

import Free.AlaCarte
import Relude

type Logger :: Type -> Type
data Logger a
  = LogInfo Text a
  | LogError Text a
  | LogDebug Text a
  deriving ((forall a b. (a -> b) -> Logger a -> Logger b)
-> (forall a b. a -> Logger b -> Logger a) -> Functor Logger
forall a b. a -> Logger b -> Logger a
forall a b. (a -> b) -> Logger a -> Logger b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> Logger a -> Logger b
fmap :: forall a b. (a -> b) -> Logger a -> Logger b
$c<$ :: forall a b. a -> Logger b -> Logger a
<$ :: forall a b. a -> Logger b -> Logger a
Functor)

logInfo :: (Logger :<: f) => Text -> Free f ()
logInfo :: forall (f :: * -> *). (Logger :<: f) => Text -> Free f ()
logInfo Text
message = Logger (Free f ()) -> Free f ()
forall (g :: * -> *) (f :: * -> *) a.
(g :<: f) =>
g (Free f a) -> Free f a
injectFree (Text -> Free f () -> Logger (Free f ())
forall a. Text -> a -> Logger a
LogInfo Text
message (() -> Free f ()
forall (f :: * -> *) a. a -> Free f a
Pure ()))

logError :: (Logger :<: f) => Text -> Free f ()
logError :: forall (f :: * -> *). (Logger :<: f) => Text -> Free f ()
logError Text
message = Logger (Free f ()) -> Free f ()
forall (g :: * -> *) (f :: * -> *) a.
(g :<: f) =>
g (Free f a) -> Free f a
injectFree (Text -> Free f () -> Logger (Free f ())
forall a. Text -> a -> Logger a
LogError Text
message (() -> Free f ()
forall (f :: * -> *) a. a -> Free f a
Pure ()))

logDebug :: (Logger :<: f) => Text -> Free f ()
logDebug :: forall (f :: * -> *). (Logger :<: f) => Text -> Free f ()
logDebug Text
message = Logger (Free f ()) -> Free f ()
forall (g :: * -> *) (f :: * -> *) a.
(g :<: f) =>
g (Free f a) -> Free f a
injectFree (Text -> Free f () -> Logger (Free f ())
forall a. Text -> a -> Logger a
LogDebug Text
message (() -> Free f ()
forall (f :: * -> *) a. a -> Free f a
Pure ()))