{-# LANGUAGE GHC2021 #-} {-# LANGUAGE OverloadedRecordDot #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE DataKinds #-} module Main where import Data.Function import Effectful import Effectful.Reader.Static import Control.Monad.IO.Class data Config = Config { counter :: Int } deriving stock (Eq, Show) runOperations :: Eff [Reader Config, IOE] () -> IO () runOperations operations = operations & runReader (Config 0) & runEff operations :: Eff [Reader Config, IOE] () operations = do newCounter <- useConfig liftIO $ print newCounter useConfig :: (Reader Config :> es) => Eff es Int useConfig = asks @Config (\c -> c.counter +1) main :: IO () main = runOperations operations