module Stratosphere.Prelude (module Exports, maybeField) where
import Data.Aeson as Exports ((.=))
import Data.Kind as Exports (Type)
import Data.Map.Strict as Exports (Map)
import Data.Maybe as Exports (catMaybes)
import Data.MonoTraversable as Exports
import Data.Text as Exports (Text)
import GHC.Exts as Exports (fromList)
import GHC.Generics as Exports (Generic)
import Prelude as Exports
import qualified Data.Aeson as JSON
maybeField
:: JSON.ToJSON a
=> JSON.Key
-> Maybe a
-> Maybe (JSON.Key, JSON.Value)
maybeField :: forall a. ToJSON a => Key -> Maybe a -> Maybe (Key, Value)
maybeField Key
field = (a -> (Key, Value)) -> Maybe a -> Maybe (Key, Value)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Key
field Key -> Value -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=) (Value -> (Key, Value)) -> (a -> Value) -> a -> (Key, Value)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Value
forall a. ToJSON a => a -> Value
JSON.toJSON)