graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.Prelude

Synopsis

Documentation

onNothing :: Applicative m => Maybe a -> m a -> m a Source #

onNothingM :: Monad m => m (Maybe a) -> m a -> m a Source #

onJust :: Applicative m => Maybe a -> (a -> m ()) -> m () Source #

withJust :: Applicative m => Maybe a -> (a -> m (Maybe b)) -> m (Maybe b) Source #

maybeToEither :: a -> Maybe b -> Either a b Source #

Transform a Maybe into an Either given a default value.

maybeToEither def Nothing == Left def
maybeToEither _def (Just b) == Right b

eitherToMaybe :: Either a b -> Maybe b Source #

Convert an Either to a Maybe, forgetting the Left values.

eitherToMaybe (Left a) == Nothing
eitherToMaybe (Right b) == Just b

onLeft :: Applicative m => Either e a -> (e -> m a) -> m a Source #

mapLeft :: (e1 -> e2) -> Either e1 a -> Either e2 a Source #

whenMaybe :: Applicative m => Bool -> m a -> m (Maybe a) Source #

choice :: Alternative f => [f a] -> f a Source #

afold :: (Foldable t, Alternative f) => t a -> f a Source #

liftEitherM :: MonadError e m => m (Either e a) -> m a Source #

spanMaybeM :: (Foldable f, Monad m) => (a -> m (Maybe b)) -> f a -> m ([b], [a]) Source #

findWithIndex :: (a -> Bool) -> [a] -> Maybe (a, Int) Source #

mapFromL :: (Eq k, Hashable k) => (a -> k) -> [a] -> HashMap k a Source #

oMapFromL :: (Eq k, Hashable k) => (a -> k) -> [a] -> InsOrdHashMap k a Source #

withElapsedTime :: MonadIO m => m a -> m (DiffTime, a) Source #

Time an IO action, returning the time with microsecond precision. The result of the input action will be evaluated to WHNF.

The result DiffTime is guarenteed to be >= 0.

startTimer :: (MonadIO m, MonadIO n) => m (n DiffTime) Source #

Start timing and return an action to return the elapsed time since startTimer was called.

  timer <- startTimer
  someStuffToTime
  elapsed <- timer
  moreStuff
  elapsedBoth <- timer

tshow :: Show a => a -> Text Source #

readJson :: FromJSON a => String -> Either String a Source #

hasuraJSON :: Options Source #

Customized Options which apply "snake case" to Generic or Template Haskell JSON derivations.

For example, a Haskell field fooBar would be deserialized fromto JSON as foo_bar.

ltrace :: Show a => String -> a -> a Source #

Warning: ltrace left in code

Labeled, prettified traceShowId

ltraceM :: Applicative m => Show a => String -> a -> m () Source #

Warning: ltraceM left in code

Labeled, prettified traceShowM

traceToFile :: Show a => FilePath -> a -> a Source #

Warning: traceToFile left in code

Trace a prettified value to a file

traceToFileM :: Applicative m => Show a => FilePath -> a -> m () Source #

Warning: traceToFileM left in code

Trace a prettified value to a file in an Applicative context

hashNub :: (Hashable a, Eq a) => [a] -> [a] Source #

Remove duplicates from a list. Like nub but runs in O(n * log_16(n)) time and requires Hashable and Eq instances. hashNub is faster than ordNub when there're not so many different values in the list.

>>> hashNub [1,3,2,9,4,1,5,7,3,3,1,2,5,4,3,2,1,0]
[0,1,2,3,4,5,7,9]

nonEmptySeqToNonEmptyList :: NESeq a -> NonEmpty a Source #

Convert a non-empty sequence to a non-empty list.