HasConf for Reader

This commit is contained in:
Dmitry Zuikov 2023-10-03 04:47:51 +03:00
parent eef1561340
commit a0919addd3
2 changed files with 8 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import Data.Maybe
import Data.Scientific
import Data.Aeson
import Prettyprinter
import Control.Monad.Reader
import Safe
type C = MegaParsec
@ -31,6 +32,12 @@ pattern Key :: forall {c}. Id -> [Syntax c] -> [Syntax c]
pattern Key n ns <- SymbolVal n : ns
instance HasConf (Reader [Syntax C]) where
getConf = ask
instance Monad m => HasConf (ReaderT [Syntax C] m) where
getConf = ask
instance {-# OVERLAPPABLE #-} (HasConf m, HasCfgKey a (Maybe Integer) m) => HasCfgValue a (Maybe Integer) m where
cfgValue = lastMay . val <$> getConf
where

View File

@ -75,6 +75,7 @@ library
, bytestring
, containers
, megaparsec
, mtl
, prettyprinter
, safe
, scientific