HasConf for Reader
This commit is contained in:
parent
eef1561340
commit
a0919addd3
|
@ -13,6 +13,7 @@ import Data.Maybe
|
||||||
import Data.Scientific
|
import Data.Scientific
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
import Prettyprinter
|
import Prettyprinter
|
||||||
|
import Control.Monad.Reader
|
||||||
import Safe
|
import Safe
|
||||||
|
|
||||||
type C = MegaParsec
|
type C = MegaParsec
|
||||||
|
@ -31,6 +32,12 @@ pattern Key :: forall {c}. Id -> [Syntax c] -> [Syntax c]
|
||||||
pattern Key n ns <- SymbolVal n : ns
|
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
|
instance {-# OVERLAPPABLE #-} (HasConf m, HasCfgKey a (Maybe Integer) m) => HasCfgValue a (Maybe Integer) m where
|
||||||
cfgValue = lastMay . val <$> getConf
|
cfgValue = lastMay . val <$> getConf
|
||||||
where
|
where
|
||||||
|
|
|
@ -75,6 +75,7 @@ library
|
||||||
, bytestring
|
, bytestring
|
||||||
, containers
|
, containers
|
||||||
, megaparsec
|
, megaparsec
|
||||||
|
, mtl
|
||||||
, prettyprinter
|
, prettyprinter
|
||||||
, safe
|
, safe
|
||||||
, scientific
|
, scientific
|
||||||
|
|
Loading…
Reference in New Issue