{-# LANGUAGE TypeFamilies, MultiParamTypeClasses, FlexibleInstances #-}
module Simulation.Aivika.Lattice.Ref.Base.Lazy () where
import Simulation.Aivika.Trans.Internal.Types
import Simulation.Aivika.Trans.Comp
import Simulation.Aivika.Trans.Simulation
import Simulation.Aivika.Trans.Ref.Base.Lazy
import Simulation.Aivika.Trans.Observable
import Simulation.Aivika.Lattice.Internal.LIO
import qualified Simulation.Aivika.Lattice.Internal.Ref.Lazy as R
import Simulation.Aivika.Lattice.Internal.Estimate
import Simulation.Aivika.Lattice.Internal.Event
instance MonadRef LIO where
newtype Ref LIO a = Ref { forall a. Ref LIO a -> Ref a
refValue :: R.Ref a }
{-# INLINE newRef #-}
newRef :: forall a. a -> Simulation LIO (Ref LIO a)
newRef = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Ref a -> Ref LIO a
Ref forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Simulation LIO (Ref a)
R.newRef
{-# INLINE readRef #-}
readRef :: forall a. Ref LIO a -> Event LIO a
readRef (Ref Ref a
r) = forall a. Ref a -> Event LIO a
R.readRef Ref a
r
{-# INLINE writeRef #-}
writeRef :: forall a. Ref LIO a -> a -> Event LIO ()
writeRef (Ref Ref a
r) = forall a. Ref a -> a -> Event LIO ()
R.writeRef Ref a
r
{-# INLINE modifyRef #-}
modifyRef :: forall a. Ref LIO a -> (a -> a) -> Event LIO ()
modifyRef (Ref Ref a
r) = forall a. Ref a -> (a -> a) -> Event LIO ()
R.modifyRef Ref a
r
{-# INLINE equalRef #-}
equalRef :: forall a. Ref LIO a -> Ref LIO a -> Bool
equalRef (Ref Ref a
r1) (Ref Ref a
r2) = (Ref a
r1 forall a. Eq a => a -> a -> Bool
== Ref a
r2)
instance MonadRef0 LIO where
{-# INLINE newRef0 #-}
newRef0 :: forall a. a -> LIO (Ref LIO a)
newRef0 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Ref a -> Ref LIO a
Ref forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> LIO (Ref a)
R.newRef0
instance Observable (Ref LIO) (Estimate LIO) where
{-# INLINE readObservable #-}
readObservable :: forall a. Ref LIO a -> Estimate LIO a
readObservable (Ref Ref a
r) = forall a. Ref a -> Estimate LIO a
estimateLazyRef Ref a
r