{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE StandaloneDeriving #-}

{-# OPTIONS_GHC -Wno-orphans #-}

module Test.Util.Orphans.NoThunks () where

import           Control.Concurrent.Class.MonadMVar
import           Control.Concurrent.Class.MonadSTM.Strict.TVar.Checked
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.NormalForm
import           Ouroboros.Consensus.Util.NormalForm.StrictMVar
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 a => NoThunks (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
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 -> InspectMonad (IOSim s) a)
-> TVar (IOSim s) a -> InspectMonad (IOSim s) a
forall a b. (a -> b) -> a -> b
$ StrictTVar (IOSim s) a -> TVar (IOSim s) a
forall (m :: * -> *) a. StrictTVar m a -> LazyTVar m a
toLazyTVar StrictTVar (IOSim s) a
tvar
      Context -> a -> IO (Maybe ThunkInfo)
forall a. NoThunks a => Context -> a -> IO (Maybe ThunkInfo)
noThunks Context
ctxt a
a

{-------------------------------------------------------------------------------
  fs-sim
-------------------------------------------------------------------------------}

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