{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Test.Util.Orphans.NoThunks () where
import Control.Concurrent.Class.MonadMVar
import Control.Concurrent.Class.MonadMVar.Strict
import Control.Concurrent.Class.MonadSTM.Strict
import Control.Monad.IOSim
import Control.Monad.ST.Lazy
import Control.Monad.ST.Unsafe (unsafeSTToIO)
import Data.Proxy
import NoThunks.Class (NoThunks (..))
import Ouroboros.Consensus.Util.MonadSTM.StrictSVar
import qualified Ouroboros.Consensus.Util.NormalForm.StrictMVar as NormalForm
import qualified Ouroboros.Consensus.Util.NormalForm.StrictTVar as NormalForm
import System.FS.API.Types
import System.FS.Sim.FsTree
import System.FS.Sim.MockFS
instance NoThunks a => NoThunks (StrictSVar (IOSim s) a) where
showTypeOf :: Proxy (StrictSVar (IOSim s) a) -> String
showTypeOf Proxy (StrictSVar (IOSim s) a)
_ = String
"StrictSVar IOSim"
wNoThunks :: Context -> StrictSVar (IOSim s) a -> IO (Maybe ThunkInfo)
wNoThunks Context
ctxt StrictSVar { TVar (IOSim s) a
tvar :: TVar (IOSim s) a
tvar :: forall (m :: * -> *) a. StrictSVar m a -> TVar m a
tvar } = do
a
a <- ST s a -> IO a
forall s a. ST s a -> IO a
unsafeSTToIO (ST s a -> IO a) -> ST s a -> IO a
forall a b. (a -> b) -> a -> b
$ ST s a -> ST s a
forall s a. ST s a -> ST s a
lazyToStrictST (ST s a -> ST s a) -> ST s a -> ST s a
forall a b. (a -> b) -> a -> b
$ Proxy (IOSim s) -> TVar (IOSim s) a -> InspectMonad (IOSim s) a
forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadInspectSTM m =>
proxy m -> TVar m a -> InspectMonad m a
forall (proxy :: (* -> *) -> *) a.
proxy (IOSim s) -> TVar (IOSim s) a -> InspectMonad (IOSim s) a
inspectTVar (Proxy (IOSim s)
forall {s}. Proxy (IOSim s)
forall {k} (t :: k). Proxy t
Proxy :: Proxy (IOSim s)) TVar (IOSim s) a
tvar
Context -> a -> IO (Maybe ThunkInfo)
forall a. NoThunks a => Context -> a -> IO (Maybe ThunkInfo)
noThunks Context
ctxt a
a
instance NoThunks a => NoThunks (StrictMVar (IOSim s) a) where
showTypeOf :: Proxy (StrictMVar (IOSim s) a) -> String
showTypeOf Proxy (StrictMVar (IOSim s) a)
_ = String
"StrictMVar IOSim"
wNoThunks :: Context -> StrictMVar (IOSim s) a -> IO (Maybe ThunkInfo)
wNoThunks Context
ctxt StrictMVar (IOSim s) a
mvar = do
Maybe a
aMay <- ST s (Maybe a) -> IO (Maybe a)
forall s a. ST s a -> IO a
unsafeSTToIO (ST s (Maybe a) -> IO (Maybe a)) -> ST s (Maybe a) -> IO (Maybe a)
forall a b. (a -> b) -> a -> b
$ ST s (Maybe a) -> ST s (Maybe a)
forall s a. ST s a -> ST s a
lazyToStrictST (ST s (Maybe a) -> ST s (Maybe a))
-> ST s (Maybe a) -> ST s (Maybe a)
forall a b. (a -> b) -> a -> b
$ Proxy (IOSim s)
-> MVar (IOSim s) a -> InspectMVarMonad (IOSim s) (Maybe a)
forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadInspectMVar m =>
proxy m -> MVar m a -> InspectMVarMonad m (Maybe a)
forall (proxy :: (* -> *) -> *) a.
proxy (IOSim s)
-> MVar (IOSim s) a -> InspectMVarMonad (IOSim s) (Maybe a)
inspectMVar (Proxy (IOSim s)
forall {s}. Proxy (IOSim s)
forall {k} (t :: k). Proxy t
Proxy :: Proxy (IOSim s)) (StrictMVar (IOSim s) a -> MVar (IOSim s) a
forall (m :: * -> *) a. StrictMVar m a -> LazyMVar m a
toLazyMVar StrictMVar (IOSim s) a
mvar)
Context -> Maybe a -> IO (Maybe ThunkInfo)
forall a. NoThunks a => Context -> a -> IO (Maybe ThunkInfo)
noThunks Context
ctxt Maybe a
aMay
instance NoThunks (StrictMVar (IOSim s) a) => NoThunks (NormalForm.StrictMVar (IOSim s) a) where
showTypeOf :: Proxy (StrictMVar (IOSim s) a) -> String
showTypeOf Proxy (StrictMVar (IOSim s) a)
_ = String
"StrictMVar IOSim"
wNoThunks :: Context -> StrictMVar (IOSim s) a -> IO (Maybe ThunkInfo)
wNoThunks Context
ctxt StrictMVar (IOSim s) a
mvar = Context -> StrictMVar (IOSim s) a -> IO (Maybe ThunkInfo)
forall a. NoThunks a => Context -> a -> IO (Maybe ThunkInfo)
wNoThunks Context
ctxt (StrictMVar (IOSim s) a -> StrictMVar (IOSim s) a
forall (m :: * -> *) a. StrictMVar m a -> StrictMVar m a
NormalForm.unsafeToUncheckedStrictMVar StrictMVar (IOSim s) a
mvar)
instance NoThunks (StrictTVar (IOSim s) a) => NoThunks (NormalForm.StrictTVar (IOSim s) a) where
showTypeOf :: Proxy (StrictTVar (IOSim s) a) -> String
showTypeOf Proxy (StrictTVar (IOSim s) a)
_ = String
"StrictTVar IOSim"
wNoThunks :: Context -> StrictTVar (IOSim s) a -> IO (Maybe ThunkInfo)
wNoThunks Context
ctxt StrictTVar (IOSim s) a
tv = Context -> StrictTVar (IOSim s) a -> IO (Maybe ThunkInfo)
forall a. NoThunks a => Context -> a -> IO (Maybe ThunkInfo)
wNoThunks Context
ctxt (StrictTVar (IOSim s) a -> StrictTVar (IOSim s) a
forall (m :: * -> *) a. StrictTVar m a -> StrictTVar m a
NormalForm.unsafeToUncheckedStrictTVar StrictTVar (IOSim s) a
tv)
deriving instance NoThunks FsPath
deriving instance NoThunks MockFS
deriving instance NoThunks a => NoThunks (FsTree a)
deriving instance NoThunks HandleMock
deriving instance NoThunks HandleState
deriving instance NoThunks OpenHandleState
deriving instance NoThunks ClosedHandleState
deriving instance NoThunks FilePtr