License | BSD-3-Clause |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Swarm.Util.Yaml
Description
Various utilities related to parsing YAML files.
Synopsis
- newtype With e (f :: Type -> Type) a = E {
- runE :: e -> f a
- type ParserE e = With e Parser
- liftE :: Functor f => f a -> With e f a
- localE :: forall e' e (f :: Type -> Type) a. (e' -> e) -> With e f a -> With e' f a
- withE :: forall e (f :: Type -> Type) a. Semigroup e => e -> With e f a -> With e f a
- getE :: forall (f :: Type -> Type) e. Monad f => With e f e
- class FromJSONE e a where
- parseJSONE :: Value -> ParserE e a
- parseJSONE' :: e -> Value -> Parser a
- decodeFileEitherE :: FromJSONE e a => e -> FilePath -> IO (Either ParseException a)
- (..:) :: FromJSONE e a => Object -> Text -> ParserE e a
- (..:?) :: FromJSONE e a => Object -> Text -> ParserE e (Maybe a)
- (..!=) :: Functor f => f (Maybe a) -> a -> f a
- withTextE :: String -> (Text -> ParserE e a) -> Value -> ParserE e a
- withObjectE :: String -> (Object -> ParserE e a) -> Value -> ParserE e a
- withArrayE :: String -> (Array -> ParserE e a) -> Value -> ParserE e a
Documentation
newtype With e (f :: Type -> Type) a Source #
A generic wrapper for computations which also depend on knowing a
value of type e
.
liftE :: Functor f => f a -> With e f a Source #
Lift a computation that does not care about the environment value.
localE :: forall e' e (f :: Type -> Type) a. (e' -> e) -> With e f a -> With e' f a Source #
Locally modify an environment.
withE :: forall e (f :: Type -> Type) a. Semigroup e => e -> With e f a -> With e f a Source #
Locally merge an environment with the current one for given action.
class FromJSONE e a where Source #
FromJSONE
governs values that can be parsed from a YAML (or
JSON) file, but which also have access to an extra, read-only
environment value.
For things that don't care about the environment, the default
implementation of parseJSONE
simply calls parseJSON
from a
FromJSON
instance.
Minimal complete definition
Nothing
Instances
FromJSONE e Int Source # | |
Defined in Swarm.Util.Yaml | |
FromJSONE e a => FromJSONE e [a] Source # | |
Defined in Swarm.Util.Yaml Methods parseJSONE :: Value -> ParserE e [a] Source # parseJSONE' :: e -> Value -> Parser [a] Source # | |
(FromJSONE e a, FromJSONE e b) => FromJSONE e (a, b) Source # | |
Defined in Swarm.Util.Yaml Methods parseJSONE :: Value -> ParserE e (a, b) Source # parseJSONE' :: e -> Value -> Parser (a, b) Source # |
decodeFileEitherE :: FromJSONE e a => e -> FilePath -> IO (Either ParseException a) Source #
Read a value from a YAML file, providing the needed extra environment.