Reject MonadUnique, embrace IO

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7751
GitOrigin-RevId: 3edc4dee10d58afac911c9862e3b55a4c458a293
This commit is contained in:
Tom Harding 2023-02-01 18:56:15 +00:00 committed by hasura-bot
parent c663cb9879
commit e41654b133
8 changed files with 6 additions and 78 deletions

View File

@ -297,7 +297,6 @@ common lib-depends
, lifted-base
, monad-control
, monad-loops
, monad-unique
, monad-validate
, mtl
, nonempty-containers

View File

@ -32,7 +32,6 @@ library
, dependent-map
, dependent-sum
, hasura-prelude
, monad-unique
, profunctors
, reflection
, some
@ -89,7 +88,6 @@ test-suite hasura-incremental-tests
, hasura-incremental
, hasura-prelude
, hspec
, monad-unique
, unordered-containers
build-tool-depends:

View File

@ -8,7 +8,6 @@ module Hasura.Incremental.Internal.Cache
where
import Control.Arrow.Extended
import Control.Monad.Unique
import Data.Reflection
import Hasura.Incremental.Internal.Dependency
import Hasura.Incremental.Internal.Rule
@ -55,7 +54,7 @@ instance (Monoid w, ArrowCache m arr) => ArrowCache m (WriterA w arr) where
dependOn = liftA dependOn
{-# INLINE dependOn #-}
instance (MonadUnique m) => ArrowCache m (Rule m) where
instance MonadIO m => ArrowCache m (Rule m) where
cache ::
forall a b.
(Given Accesses => Eq a) =>

View File

@ -296,7 +296,7 @@ class (Arrow arr) => ArrowDistribute arr where
-- This is intended to be used as a control operator in @proc@ notation; see
-- Note [Weird control operator types] in "Control.Arrow.Extended".
keyed ::
(Eq k, Hashable k) =>
Hashable k =>
arr (e, (k, (a, s))) b ->
arr (e, (HashMap k a, s)) (HashMap k b)

View File

@ -19,13 +19,13 @@ module Hasura.Incremental.Select
)
where
import Control.Monad.Unique
import Data.Dependent.Map qualified as DM
import "some" Data.GADT.Compare
import Data.HashMap.Strict qualified as M
import Data.Kind
import Data.Proxy (Proxy (..))
import Data.Type.Equality
import Data.Unique (Unique, newUnique)
import GHC.OverloadedLabels (IsLabel (..))
import GHC.Records (HasField (..))
import GHC.TypeLits (KnownSymbol, sameSymbol, symbolVal)
@ -137,8 +137,8 @@ type role UniqueS nominal
newtype UniqueS a = UniqueS Unique
deriving (Eq)
newUniqueS :: (MonadUnique m) => m (UniqueS a)
newUniqueS = UniqueS <$> newUnique
newUniqueS :: MonadIO m => m (UniqueS a)
newUniqueS = UniqueS <$> liftIO newUnique
{-# INLINE newUniqueS #-}
instance GEq UniqueS where

View File

@ -1,35 +0,0 @@
cabal-version: 2.2
name: monad-unique
version: 1.0.0
build-type: Simple
copyright: Hasura Inc.
extra-source-files: README.md
library
hs-source-dirs: src
default-language: GHC2021
ghc-options:
-- Taken from https://medium.com/mercury-bank/enable-all-the-warnings-a0517bc081c3
-Weverything
-Wno-missing-exported-signatures
-Wno-missing-import-lists
-Wno-missed-specialisations
-Wno-all-missed-specialisations
-Wno-unsafe
-Wno-safe
-Wno-missing-local-signatures
-Wno-monomorphism-restriction
-Wno-missing-kind-signatures
-Wno-missing-safe-haskell-mode
-- We want these warnings, but the code doesn't satisfy them yet:
-Wno-missing-deriving-strategies
-Wno-unused-packages
build-depends:
, base
, mtl
, transformers
exposed-modules:
Control.Monad.Unique

View File

@ -1,31 +0,0 @@
-- | A tiny mtl-style wrapper around 'U.newUnique'.
module Control.Monad.Unique
( U.Unique,
MonadUnique (..),
)
where
import Control.Monad.Except (ExceptT)
import Control.Monad.Reader (ReaderT)
import Control.Monad.State.Strict (StateT)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Writer.Strict (WriterT)
import Data.Unique qualified as U
class (Monad m) => MonadUnique m where
newUnique :: m U.Unique
instance MonadUnique IO where
newUnique = U.newUnique
instance (MonadUnique m) => MonadUnique (ExceptT e m) where
newUnique = lift newUnique
instance (MonadUnique m) => MonadUnique (ReaderT r m) where
newUnique = lift newUnique
instance (MonadUnique m) => MonadUnique (StateT s m) where
newUnique = lift newUnique
instance (Monoid w, MonadUnique m) => MonadUnique (WriterT w m) where
newUnique = lift newUnique

View File

@ -48,7 +48,6 @@ import Control.Arrow.Extended
import Control.Arrow.Interpret
import Control.Lens
import Control.Monad.Trans.Control (MonadBaseControl)
import Control.Monad.Unique
import Data.Aeson.Extended
import Data.HashMap.Strict.Extended qualified as M
import Data.HashMap.Strict.InsOrd qualified as OMap
@ -270,8 +269,7 @@ newtype CacheBuild a = CacheBuild (ReaderT CacheBuildParams (ExceptT QErr IO) a)
MonadReader CacheBuildParams,
MonadIO,
MonadBase IO,
MonadBaseControl IO,
MonadUnique
MonadBaseControl IO
)
instance HasHttpManagerM CacheBuild where