mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 09:51:59 +03:00
7b5bbb758a
Use 'Strict' State monad instead of 'Lazy' to avoid unevaluated memory thunks
48 lines
2.1 KiB
Haskell
48 lines
2.1 KiB
Haskell
module Hasura.Prelude
|
|
( module M
|
|
, onNothing
|
|
, onJust
|
|
, onLeft
|
|
) where
|
|
|
|
import Control.Applicative as M ((<|>))
|
|
import Control.Monad as M (void, when)
|
|
import Control.Monad.Base as M
|
|
import Control.Monad.Except as M
|
|
import Control.Monad.Fail as M (MonadFail)
|
|
import Control.Monad.Identity as M
|
|
import Control.Monad.Reader as M
|
|
import Control.Monad.State.Strict as M
|
|
import Data.Bool as M (bool)
|
|
import Data.Either as M (lefts, partitionEithers,
|
|
rights)
|
|
import Data.Foldable as M (foldrM, toList)
|
|
import Data.Hashable as M (Hashable)
|
|
import Data.List as M (find, foldl', group,
|
|
intercalate, intersect,
|
|
lookup, sort, sortBy, sortOn,
|
|
union, unionBy, (\\))
|
|
import Data.Maybe as M (catMaybes, fromMaybe, isJust,
|
|
isNothing, listToMaybe,
|
|
mapMaybe, maybeToList)
|
|
import Data.Ord as M (comparing)
|
|
import Data.Semigroup as M (Semigroup (..))
|
|
import Data.String as M (IsString)
|
|
import Data.Text as M (Text)
|
|
import Data.Word as M (Word64)
|
|
import GHC.Generics as M (Generic)
|
|
import Prelude as M hiding (fail, init, lookup)
|
|
import Text.Read as M (readEither, readMaybe)
|
|
|
|
onNothing :: (Monad m) => Maybe a -> m a -> m a
|
|
onNothing m act = maybe act return m
|
|
|
|
onJust :: (Monad m) => Maybe a -> (a -> m ()) -> m ()
|
|
onJust m action = maybe (return ()) action m
|
|
|
|
onLeft :: (Monad m) => Either e a -> (e -> m a) -> m a
|
|
onLeft e f = either f return e
|
|
|
|
|
|
|