HasConf for Reader
This commit is contained in:
parent
eef1561340
commit
a0919addd3
|
@ -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
|
||||
|
|
|
@ -75,6 +75,7 @@ library
|
|||
, bytestring
|
||||
, containers
|
||||
, megaparsec
|
||||
, mtl
|
||||
, prettyprinter
|
||||
, safe
|
||||
, scientific
|
||||
|
|
Loading…
Reference in New Issue