[add] an elaborator for the Provider effect.

This commit is contained in:
Yamada Ryo 2023-09-05 17:46:17 +09:00
parent 70d1a54830
commit 4abedf3e97
No known key found for this signature in database
GPG Key ID: AAE3C7A542B02DBF
2 changed files with 19 additions and 0 deletions

View File

@ -39,6 +39,7 @@ library
Control.Effect.Handler.Heftia.Writer
Control.Effect.Handler.Heftia.State
Control.Effect.Handler.Heftia.Except
Control.Effect.Handler.Heftia.Provider
-- Modules included in this executable, other than Main.
-- other-modules:

View File

@ -0,0 +1,18 @@
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at https://mozilla.org/MPL/2.0/.
module Control.Effect.Handler.Heftia.Provider where
import Control.Effect.Class (type (~>))
import Control.Effect.Class.Provider (ProviderS (Provide))
import Control.Effect.Freer (Fre)
import Control.Monad.Trans (MonadTrans, lift)
-- | Elaborate the 'Provider' effect using the given interpreter for some monad transformer.
elaborateProviderT ::
(Monad m, MonadTrans t, c (t (Fre es m))) =>
(forall x. i -> t (Fre es m) x -> Fre es m (g x)) ->
ProviderS c i g (Fre es m) ~> Fre es m
elaborateProviderT run (Provide i m) = run i $ m lift
{-# INLINE elaborateProviderT #-}