{-# LANGUAGE TypeFamilies, MultiParamTypeClasses #-}
module Simulation.Aivika.Trans.Ref.Base.Strict
(MonadRef(..),
MonadRef0(..)) where
import Data.IORef
import Control.Monad
import Control.Monad.Trans
import Simulation.Aivika.Trans.Internal.Types
import Simulation.Aivika.Trans.Observable
class Monad m => MonadRef m where
data Ref m a
newRef :: a -> Simulation m (Ref m a)
readRef :: Ref m a -> Event m a
writeRef :: Ref m a -> a -> Event m ()
modifyRef :: Ref m a -> (a -> a) -> Event m ()
equalRef :: Ref m a -> Ref m a -> Bool
instance MonadRef m => Eq (Ref m a) where
{-# INLINE (==) #-}
== :: Ref m a -> Ref m a -> Bool
(==) = Ref m a -> Ref m a -> Bool
forall a. Ref m a -> Ref m a -> Bool
forall (m :: * -> *) a. MonadRef m => Ref m a -> Ref m a -> Bool
equalRef
class MonadRef m => MonadRef0 m where
newRef0 :: a -> m (Ref m a)
instance (Monad m, MonadRef m) => Observable (Ref m) (Event m) where
{-# INLINE readObservable #-}
readObservable :: forall a. Ref m a -> Event m a
readObservable = Ref m a -> Event m a
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef