graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hasura.RQL.Types.Webhook.Transform.WithOptional

Synopsis

Documentation

newtype WithOptional f result Source #

Enrich a Functor f with optionality; this is primarily useful when one wants to annotate fields as optional when using the Higher-Kinded Data pattern.

WithOptional f is equivalent to Compose Maybe f.

Constructors

WithOptional 

Fields

Instances

Instances details
FromJSON RequestTransformFns Source # 
Instance details

Defined in Hasura.RQL.Types.Webhook.Transform

ToJSON RequestTransformFns Source # 
Instance details

Defined in Hasura.RQL.Types.Webhook.Transform

Foldable f => Foldable (WithOptional f) Source # 
Instance details

Defined in Hasura.RQL.Types.Webhook.Transform.WithOptional

Methods

fold :: Monoid m => WithOptional f m -> m #

foldMap :: Monoid m => (a -> m) -> WithOptional f a -> m #

foldMap' :: Monoid m => (a -> m) -> WithOptional f a -> m #

foldr :: (a -> b -> b) -> b -> WithOptional f a -> b #

foldr' :: (a -> b -> b) -> b -> WithOptional f a -> b #

foldl :: (b -> a -> b) -> b -> WithOptional f a -> b #

foldl' :: (b -> a -> b) -> b -> WithOptional f a -> b #

foldr1 :: (a -> a -> a) -> WithOptional f a -> a #

foldl1 :: (a -> a -> a) -> WithOptional f a -> a #

toList :: WithOptional f a -> [a] #

null :: WithOptional f a -> Bool #

length :: WithOptional f a -> Int #

elem :: Eq a => a -> WithOptional f a -> Bool #

maximum :: Ord a => WithOptional f a -> a #

minimum :: Ord a => WithOptional f a -> a #

sum :: Num a => WithOptional f a -> a #

product :: Num a => WithOptional f a -> a #

Functor f => Functor (WithOptional f) Source # 
Instance details

Defined in Hasura.RQL.Types.Webhook.Transform.WithOptional

Methods

fmap :: (a -> b) -> WithOptional f a -> WithOptional f b #

(<$) :: a -> WithOptional f b -> WithOptional f a #

FromJSON (f result) => FromJSON (WithOptional f result) Source # 
Instance details

Defined in Hasura.RQL.Types.Webhook.Transform.WithOptional

ToJSON (f result) => ToJSON (WithOptional f result) Source # 
Instance details

Defined in Hasura.RQL.Types.Webhook.Transform.WithOptional

Generic (WithOptional f result) Source # 
Instance details

Defined in Hasura.RQL.Types.Webhook.Transform.WithOptional

Associated Types

type Rep (WithOptional f result) :: Type -> Type #

Methods

from :: WithOptional f result -> Rep (WithOptional f result) x #

to :: Rep (WithOptional f result) x -> WithOptional f result #

Show (f result) => Show (WithOptional f result) Source # 
Instance details

Defined in Hasura.RQL.Types.Webhook.Transform.WithOptional

Methods

showsPrec :: Int -> WithOptional f result -> ShowS #

show :: WithOptional f result -> String #

showList :: [WithOptional f result] -> ShowS #

NFData (f result) => NFData (WithOptional f result) Source # 
Instance details

Defined in Hasura.RQL.Types.Webhook.Transform.WithOptional

Methods

rnf :: WithOptional f result -> () #

Eq (f result) => Eq (WithOptional f result) Source # 
Instance details

Defined in Hasura.RQL.Types.Webhook.Transform.WithOptional

Methods

(==) :: WithOptional f result -> WithOptional f result -> Bool #

(/=) :: WithOptional f result -> WithOptional f result -> Bool #

type Rep (WithOptional f result) Source # 
Instance details

Defined in Hasura.RQL.Types.Webhook.Transform.WithOptional

type Rep (WithOptional f result) = D1 ('MetaData "WithOptional" "Hasura.RQL.Types.Webhook.Transform.WithOptional" "graphql-engine-1.0.0-inplace" 'True) (C1 ('MetaCons "WithOptional" 'PrefixI 'True) (S1 ('MetaSel ('Just "getOptional") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (f result)))))

withOptional :: forall a b f. Coercible a (f b) => Maybe a -> WithOptional f b Source #

WithOptional smart constructor for the special case of optional values that are representationally equivalent to some "wrapper" type.

For example: withOptional @HeaderTransformsAction headers == WithOptional $ fmap HeadersTransform headers

In other words: this function observes the isomorphism between Maybe a and WithOptional f b if an isomorphism exists between a and f b.

withOptionalField' :: forall a b f. (Coercible a (f b), HasCodec a) => Text -> ObjectCodec (WithOptional f b) (WithOptional f b) Source #

Define a field in an object codec that applies withOptional when decoding, and applies getOptional when encoding.

withOptionalFieldWith' :: forall a b f. Coercible a (f b) => Text -> ValueCodec a a -> ObjectCodec (WithOptional f b) (WithOptional f b) Source #

Define a field in an object codec that applies withOptional when decoding, and applies getOptional when encoding.

This version takes a codec for the underlying value type as an argument.