{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Data.Mutable.Internal (
Mutable(..)
, RefFor(..)
, DefaultMutable(..)
, GRef(..)
, gThawRef, gFreezeRef
, gCopyRef, gMoveRef, gCloneRef
, gUnsafeThawRef, gUnsafeFreezeRef
, GMutable (GRef_)
, thawHKD, freezeHKD
, copyHKD, moveHKD, cloneHKD
, unsafeThawHKD, unsafeFreezeHKD
, CoerceRef(..)
, thawCoerce, freezeCoerce
, copyCoerce, moveCoerce, cloneCoerce
, unsafeThawCoerce, unsafeFreezeCoerce
, TraverseRef(..)
, thawTraverse, freezeTraverse
, copyTraverse, moveTraverse, cloneTraverse
, unsafeThawTraverse, unsafeFreezeTraverse
, ImmutableRef(..), thawImmutable, freezeImmutable, copyImmutable
, GMutableRef(..)
, MutSumF(..)
, ListRefTuple(..)
, MapRef
) where
import Control.Monad.Primitive
import Control.Monad.Trans.Class
import Control.Monad.Trans.State
import Data.Bifunctor
import Data.Coerce
import Data.Foldable
import Data.Generics.Product.Internal.HList
import Data.Kind
import Data.List
import Data.Primitive.MutVar
import Data.Vinyl.Functor
import GHC.Generics
import qualified Data.GenericLens.Internal as GL
import qualified Data.Vinyl.XRec as X
class Mutable s a where
type Ref s a = (v :: Type) | v -> a s
type Ref s a = MutVar s a
thawRef :: (PrimMonad m, PrimState m ~ s) => a -> m (Ref s a)
freezeRef :: (PrimMonad m, PrimState m ~ s) => Ref s a -> m a
copyRef
:: (PrimMonad m, PrimState m ~ s)
=> Ref s a
-> a
-> m ()
moveRef
:: (PrimMonad m, PrimState m ~ s)
=> Ref s a
-> Ref s a
-> m ()
cloneRef :: (PrimMonad m, PrimState m ~ s) => Ref s a -> m (Ref s a)
unsafeThawRef :: (PrimMonad m, PrimState m ~ s) => a -> m (Ref s a)
unsafeFreezeRef :: (PrimMonad m, PrimState m ~ s) => Ref s a -> m a
default thawRef :: (DefaultMutable s a (Ref s a), PrimMonad m, PrimState m ~ s) => a -> m (Ref s a)
thawRef = a -> m (Ref s a)
forall s a r (m :: * -> *).
(DefaultMutable s a r, PrimMonad m, PrimState m ~ s) =>
a -> m r
defaultThawRef
default freezeRef :: (DefaultMutable s a (Ref s a), PrimMonad m, PrimState m ~ s) => Ref s a -> m a
freezeRef = Ref s a -> m a
forall s a r (m :: * -> *).
(DefaultMutable s a r, PrimMonad m, PrimState m ~ s) =>
r -> m a
defaultFreezeRef
default copyRef :: (DefaultMutable s a (Ref s a), PrimMonad m, PrimState m ~ s) => Ref s a -> a -> m ()
copyRef = Ref s a -> a -> m ()
forall s a r (m :: * -> *).
(DefaultMutable s a r, PrimMonad m, PrimState m ~ s) =>
r -> a -> m ()
defaultCopyRef
default moveRef :: (DefaultMutable s a (Ref s a), PrimMonad m, PrimState m ~ s) => Ref s a -> Ref s a -> m ()
moveRef = Ref s a -> Ref s a -> m ()
forall s a r (m :: * -> *).
(DefaultMutable s a r, PrimMonad m, PrimState m ~ s) =>
r -> r -> m ()
defaultMoveRef
default cloneRef :: (DefaultMutable s a (Ref s a), PrimMonad m, PrimState m ~ s) => Ref s a -> m (Ref s a)
cloneRef = Ref s a -> m (Ref s a)
forall s a r (m :: * -> *).
(DefaultMutable s a r, PrimMonad m, PrimState m ~ s) =>
r -> m r
defaultCloneRef
default unsafeThawRef :: (DefaultMutable s a (Ref s a), PrimMonad m, PrimState m ~ s) => a -> m (Ref s a)
unsafeThawRef = a -> m (Ref s a)
forall s a r (m :: * -> *).
(DefaultMutable s a r, PrimMonad m, PrimState m ~ s) =>
a -> m r
defaultUnsafeThawRef
default unsafeFreezeRef :: (DefaultMutable s a (Ref s a), PrimMonad m, PrimState m ~ s) => Ref s a -> m a
unsafeFreezeRef = Ref s a -> m a
forall s a r (m :: * -> *).
(DefaultMutable s a r, PrimMonad m, PrimState m ~ s) =>
r -> m a
defaultUnsafeFreezeRef
class DefaultMutable s a r | r -> a s where
defaultThawRef :: (PrimMonad m, PrimState m ~ s) => a -> m r
defaultFreezeRef :: (PrimMonad m, PrimState m ~ s) => r -> m a
defaultCopyRef :: (PrimMonad m, PrimState m ~ s) => r -> a -> m ()
defaultMoveRef :: (PrimMonad m, PrimState m ~ s) => r -> r -> m ()
defaultCloneRef :: (PrimMonad m, PrimState m ~ s) => r -> m r
defaultUnsafeThawRef :: (PrimMonad m, PrimState m ~ s) => a -> m r
defaultUnsafeFreezeRef :: (PrimMonad m, PrimState m ~ s) => r -> m a
instance DefaultMutable s a (MutVar s a) where
defaultThawRef :: a -> m (MutVar s a)
defaultThawRef = a -> m (MutVar s a)
forall (m :: * -> *) a.
PrimMonad m =>
a -> m (MutVar (PrimState m) a)
newMutVar
defaultFreezeRef :: MutVar s a -> m a
defaultFreezeRef = MutVar s a -> m a
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> m a
readMutVar
defaultCopyRef :: MutVar s a -> a -> m ()
defaultCopyRef = MutVar s a -> a -> m ()
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> a -> m ()
writeMutVar
defaultMoveRef :: MutVar s a -> MutVar s a -> m ()
defaultMoveRef v :: MutVar s a
v u :: MutVar s a
u = MutVar (PrimState m) a -> a -> m ()
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> a -> m ()
writeMutVar MutVar s a
MutVar (PrimState m) a
v (a -> m ()) -> m a -> m ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< MutVar (PrimState m) a -> m a
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> m a
readMutVar MutVar s a
MutVar (PrimState m) a
u
defaultCloneRef :: MutVar s a -> m (MutVar s a)
defaultCloneRef v :: MutVar s a
v = a -> m (MutVar s a)
forall (m :: * -> *) a.
PrimMonad m =>
a -> m (MutVar (PrimState m) a)
newMutVar (a -> m (MutVar s a)) -> m a -> m (MutVar s a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< MutVar (PrimState m) a -> m a
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> m a
readMutVar MutVar s a
MutVar (PrimState m) a
v
defaultUnsafeThawRef :: a -> m (MutVar s a)
defaultUnsafeThawRef = a -> m (MutVar s a)
forall (m :: * -> *) a.
PrimMonad m =>
a -> m (MutVar (PrimState m) a)
newMutVar
defaultUnsafeFreezeRef :: MutVar s a -> m a
defaultUnsafeFreezeRef = MutVar s a -> m a
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> m a
readMutVar
instance (Generic a, GMutable s (Rep a)) => DefaultMutable s a (GRef s a) where
defaultThawRef :: a -> m (GRef s a)
defaultThawRef = a -> m (GRef s a)
forall a s (m :: * -> *).
(Generic a, GMutable s (Rep a), PrimMonad m, PrimState m ~ s) =>
a -> m (GRef s a)
gThawRef
defaultFreezeRef :: GRef s a -> m a
defaultFreezeRef = GRef s a -> m a
forall a s (m :: * -> *).
(Generic a, GMutable s (Rep a), PrimMonad m, PrimState m ~ s) =>
GRef s a -> m a
gFreezeRef
defaultCopyRef :: GRef s a -> a -> m ()
defaultCopyRef = GRef s a -> a -> m ()
forall a s (m :: * -> *).
(Generic a, GMutable s (Rep a), PrimMonad m, PrimState m ~ s) =>
GRef s a -> a -> m ()
gCopyRef
defaultMoveRef :: GRef s a -> GRef s a -> m ()
defaultMoveRef = GRef s a -> GRef s a -> m ()
forall s a (m :: * -> *).
(GMutable s (Rep a), PrimMonad m, PrimState m ~ s) =>
GRef s a -> GRef s a -> m ()
gMoveRef
defaultCloneRef :: GRef s a -> m (GRef s a)
defaultCloneRef = GRef s a -> m (GRef s a)
forall s a (m :: * -> *).
(GMutable s (Rep a), PrimMonad m, PrimState m ~ s) =>
GRef s a -> m (GRef s a)
gCloneRef
defaultUnsafeThawRef :: a -> m (GRef s a)
defaultUnsafeThawRef = a -> m (GRef s a)
forall a s (m :: * -> *).
(Generic a, GMutable s (Rep a), PrimMonad m, PrimState m ~ s) =>
a -> m (GRef s a)
gUnsafeThawRef
defaultUnsafeFreezeRef :: GRef s a -> m a
defaultUnsafeFreezeRef = GRef s a -> m a
forall a s (m :: * -> *).
(Generic a, GMutable s (Rep a), PrimMonad m, PrimState m ~ s) =>
GRef s a -> m a
gUnsafeFreezeRef
instance (Generic (z Identity), Generic (z (RefFor s)), GMutable s (Rep (z Identity)), GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s)))
=> DefaultMutable s (z Identity) (z (RefFor s)) where
defaultThawRef :: z Identity -> m (z (RefFor s))
defaultThawRef = z Identity -> m (z (RefFor s))
forall (z :: (* -> *) -> *) (m :: * -> *) s.
(Generic (z Identity), Generic (z (RefFor s)),
GMutable s (Rep (z Identity)),
GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s)), PrimMonad m,
PrimState m ~ s) =>
z Identity -> m (z (RefFor s))
thawHKD
defaultFreezeRef :: z (RefFor s) -> m (z Identity)
defaultFreezeRef = z (RefFor s) -> m (z Identity)
forall (z :: (* -> *) -> *) (m :: * -> *) s.
(Generic (z Identity), Generic (z (RefFor s)),
GMutable s (Rep (z Identity)),
GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s)), PrimMonad m,
PrimState m ~ s) =>
z (RefFor s) -> m (z Identity)
freezeHKD
defaultCopyRef :: z (RefFor s) -> z Identity -> m ()
defaultCopyRef = z (RefFor s) -> z Identity -> m ()
forall (z :: (* -> *) -> *) (m :: * -> *) s.
(Generic (z Identity), Generic (z (RefFor s)),
GMutable s (Rep (z Identity)),
GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s)), PrimMonad m,
PrimState m ~ s) =>
z (RefFor s) -> z Identity -> m ()
copyHKD
defaultMoveRef :: z (RefFor s) -> z (RefFor s) -> m ()
defaultMoveRef = z (RefFor s) -> z (RefFor s) -> m ()
forall (z :: (* -> *) -> *) (m :: * -> *) s.
(Generic (z (RefFor s)), GMutable s (Rep (z Identity)),
GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s)), PrimMonad m,
PrimState m ~ s) =>
z (RefFor s) -> z (RefFor s) -> m ()
moveHKD
defaultCloneRef :: z (RefFor s) -> m (z (RefFor s))
defaultCloneRef = z (RefFor s) -> m (z (RefFor s))
forall (z :: (* -> *) -> *) (m :: * -> *) s.
(Generic (z (RefFor s)), GMutable s (Rep (z Identity)),
GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s)), PrimMonad m,
PrimState m ~ s) =>
z (RefFor s) -> m (z (RefFor s))
cloneHKD
defaultUnsafeThawRef :: z Identity -> m (z (RefFor s))
defaultUnsafeThawRef = z Identity -> m (z (RefFor s))
forall (z :: (* -> *) -> *) (m :: * -> *) s.
(Generic (z Identity), Generic (z (RefFor s)),
GMutable s (Rep (z Identity)),
GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s)), PrimMonad m,
PrimState m ~ s) =>
z Identity -> m (z (RefFor s))
unsafeThawHKD
defaultUnsafeFreezeRef :: z (RefFor s) -> m (z Identity)
defaultUnsafeFreezeRef = z (RefFor s) -> m (z Identity)
forall (z :: (* -> *) -> *) (m :: * -> *) s.
(Generic (z Identity), Generic (z (RefFor s)),
GMutable s (Rep (z Identity)),
GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s)), PrimMonad m,
PrimState m ~ s) =>
z (RefFor s) -> m (z Identity)
unsafeFreezeHKD
instance (Traversable f, Mutable s a) => DefaultMutable s (f a) (TraverseRef s f a) where
defaultThawRef :: f a -> m (TraverseRef s f a)
defaultThawRef = f a -> m (TraverseRef s f a)
forall (f :: * -> *) s a (m :: * -> *).
(Traversable f, Mutable s a, PrimMonad m, PrimState m ~ s) =>
f a -> m (TraverseRef s f a)
thawTraverse
defaultFreezeRef :: TraverseRef s f a -> m (f a)
defaultFreezeRef = TraverseRef s f a -> m (f a)
forall (f :: * -> *) s a (m :: * -> *).
(Traversable f, Mutable s a, PrimMonad m, PrimState m ~ s) =>
TraverseRef s f a -> m (f a)
freezeTraverse
defaultCopyRef :: TraverseRef s f a -> f a -> m ()
defaultCopyRef = TraverseRef s f a -> f a -> m ()
forall (f :: * -> *) s a (m :: * -> *).
(Traversable f, Mutable s a, PrimMonad m, PrimState m ~ s) =>
TraverseRef s f a -> f a -> m ()
copyTraverse
defaultMoveRef :: TraverseRef s f a -> TraverseRef s f a -> m ()
defaultMoveRef = TraverseRef s f a -> TraverseRef s f a -> m ()
forall (f :: * -> *) s a (m :: * -> *).
(Traversable f, Mutable s a, PrimMonad m, PrimState m ~ s) =>
TraverseRef s f a -> TraverseRef s f a -> m ()
moveTraverse
defaultCloneRef :: TraverseRef s f a -> m (TraverseRef s f a)
defaultCloneRef = TraverseRef s f a -> m (TraverseRef s f a)
forall (f :: * -> *) s a (m :: * -> *).
(Traversable f, Mutable s a, PrimMonad m, PrimState m ~ s) =>
TraverseRef s f a -> m (TraverseRef s f a)
cloneTraverse
defaultUnsafeThawRef :: f a -> m (TraverseRef s f a)
defaultUnsafeThawRef = f a -> m (TraverseRef s f a)
forall (f :: * -> *) s a (m :: * -> *).
(Traversable f, Mutable s a, PrimMonad m, PrimState m ~ s) =>
f a -> m (TraverseRef s f a)
unsafeThawTraverse
defaultUnsafeFreezeRef :: TraverseRef s f a -> m (f a)
defaultUnsafeFreezeRef = TraverseRef s f a -> m (f a)
forall (f :: * -> *) s a (m :: * -> *).
(Traversable f, Mutable s a, PrimMonad m, PrimState m ~ s) =>
TraverseRef s f a -> m (f a)
unsafeFreezeTraverse
instance (Coercible b a, Mutable s a) => DefaultMutable s b (CoerceRef s b a) where
defaultThawRef :: b -> m (CoerceRef s b a)
defaultThawRef = b -> m (CoerceRef s b a)
forall b a s (m :: * -> *).
(Coercible b a, Mutable s a, PrimMonad m, PrimState m ~ s) =>
b -> m (CoerceRef s b a)
thawCoerce
defaultFreezeRef :: CoerceRef s b a -> m b
defaultFreezeRef = CoerceRef s b a -> m b
forall b a s (m :: * -> *).
(Coercible b a, Mutable s a, PrimMonad m, PrimState m ~ s) =>
CoerceRef s b a -> m b
freezeCoerce
defaultCopyRef :: CoerceRef s b a -> b -> m ()
defaultCopyRef = CoerceRef s b a -> b -> m ()
forall b a s (m :: * -> *).
(Coercible b a, Mutable s a, PrimMonad m, PrimState m ~ s) =>
CoerceRef s b a -> b -> m ()
copyCoerce
defaultMoveRef :: CoerceRef s b a -> CoerceRef s b a -> m ()
defaultMoveRef = CoerceRef s b a -> CoerceRef s b a -> m ()
forall k s a (m :: * -> *) (b :: k).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
CoerceRef s b a -> CoerceRef s b a -> m ()
moveCoerce
defaultCloneRef :: CoerceRef s b a -> m (CoerceRef s b a)
defaultCloneRef = CoerceRef s b a -> m (CoerceRef s b a)
forall k s a (m :: * -> *) (b :: k).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
CoerceRef s b a -> m (CoerceRef s b a)
cloneCoerce
defaultUnsafeThawRef :: b -> m (CoerceRef s b a)
defaultUnsafeThawRef = b -> m (CoerceRef s b a)
forall b a s (m :: * -> *).
(Coercible b a, Mutable s a, PrimMonad m, PrimState m ~ s) =>
b -> m (CoerceRef s b a)
unsafeThawCoerce
defaultUnsafeFreezeRef :: CoerceRef s b a -> m b
defaultUnsafeFreezeRef = CoerceRef s b a -> m b
forall b a s (m :: * -> *).
(Coercible b a, Mutable s a, PrimMonad m, PrimState m ~ s) =>
CoerceRef s b a -> m b
unsafeFreezeCoerce
instance DefaultMutable s a (ImmutableRef s a) where
defaultThawRef :: a -> m (ImmutableRef s a)
defaultThawRef = a -> m (ImmutableRef s a)
forall k (m :: * -> *) a (s :: k).
Applicative m =>
a -> m (ImmutableRef s a)
thawImmutable
defaultFreezeRef :: ImmutableRef s a -> m a
defaultFreezeRef = ImmutableRef s a -> m a
forall k (m :: * -> *) (s :: k) a.
Applicative m =>
ImmutableRef s a -> m a
freezeImmutable
defaultCopyRef :: ImmutableRef s a -> a -> m ()
defaultCopyRef = ImmutableRef s a -> a -> m ()
forall k (m :: * -> *) (s :: k) a.
Applicative m =>
ImmutableRef s a -> a -> m ()
copyImmutable
defaultMoveRef :: ImmutableRef s a -> ImmutableRef s a -> m ()
defaultMoveRef = ImmutableRef s a -> ImmutableRef s a -> m ()
forall k (m :: * -> *) (s :: k) a.
Applicative m =>
ImmutableRef s a -> ImmutableRef s a -> m ()
moveImmutable
defaultCloneRef :: ImmutableRef s a -> m (ImmutableRef s a)
defaultCloneRef = ImmutableRef s a -> m (ImmutableRef s a)
forall k (m :: * -> *) (s :: k) a.
Applicative m =>
ImmutableRef s a -> m (ImmutableRef s a)
cloneImmutable
defaultUnsafeThawRef :: a -> m (ImmutableRef s a)
defaultUnsafeThawRef = a -> m (ImmutableRef s a)
forall k (m :: * -> *) a (s :: k).
Applicative m =>
a -> m (ImmutableRef s a)
thawImmutable
defaultUnsafeFreezeRef :: ImmutableRef s a -> m a
defaultUnsafeFreezeRef = ImmutableRef s a -> m a
forall k (m :: * -> *) (s :: k) a.
Applicative m =>
ImmutableRef s a -> m a
freezeImmutable
newtype RefFor s a = RefFor { RefFor s a -> Ref s a
getRefFor :: Ref s a }
deriving instance Eq (Ref s a) => Eq (RefFor s a)
deriving instance Ord (Ref s a) => Ord (RefFor s a)
instance X.IsoHKD (RefFor s) a where
type HKD (RefFor s) a = Ref s a
unHKD :: HKD (RefFor s) a -> RefFor s a
unHKD = HKD (RefFor s) a -> RefFor s a
forall s a. Ref s a -> RefFor s a
RefFor
toHKD :: RefFor s a -> HKD (RefFor s) a
toHKD = RefFor s a -> HKD (RefFor s) a
forall s a. RefFor s a -> Ref s a
getRefFor
newtype TraverseRef s f a = TraverseRef { TraverseRef s f a -> f (Ref s a)
getTraverseRef :: f (Ref s a) }
instance X.IsoHKD (TraverseRef s f) a where
type HKD (TraverseRef s f) a = f (Ref s a)
unHKD :: HKD (TraverseRef s f) a -> TraverseRef s f a
unHKD = HKD (TraverseRef s f) a -> TraverseRef s f a
forall s (f :: * -> *) a. f (Ref s a) -> TraverseRef s f a
TraverseRef
toHKD :: TraverseRef s f a -> HKD (TraverseRef s f) a
toHKD = TraverseRef s f a -> HKD (TraverseRef s f) a
forall s (f :: * -> *) a. TraverseRef s f a -> f (Ref s a)
getTraverseRef
thawTraverse :: (Traversable f, Mutable s a, PrimMonad m, PrimState m ~ s) => f a -> m (TraverseRef s f a)
thawTraverse :: f a -> m (TraverseRef s f a)
thawTraverse = (f (Ref s a) -> TraverseRef s f a)
-> m (f (Ref s a)) -> m (TraverseRef s f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap f (Ref s a) -> TraverseRef s f a
forall s (f :: * -> *) a. f (Ref s a) -> TraverseRef s f a
TraverseRef (m (f (Ref s a)) -> m (TraverseRef s f a))
-> (f a -> m (f (Ref s a))) -> f a -> m (TraverseRef s f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> m (Ref s a)) -> f a -> m (f (Ref s a))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> m (Ref s a)
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
a -> m (Ref s a)
thawRef
freezeTraverse :: (Traversable f, Mutable s a, PrimMonad m, PrimState m ~ s) => TraverseRef s f a -> m (f a)
freezeTraverse :: TraverseRef s f a -> m (f a)
freezeTraverse = (Ref s a -> m a) -> f (Ref s a) -> m (f a)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Ref s a -> m a
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> m a
freezeRef (f (Ref s a) -> m (f a))
-> (TraverseRef s f a -> f (Ref s a))
-> TraverseRef s f a
-> m (f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TraverseRef s f a -> f (Ref s a)
forall s (f :: * -> *) a. TraverseRef s f a -> f (Ref s a)
getTraverseRef
copyTraverse :: (Traversable f, Mutable s a, PrimMonad m, PrimState m ~ s) => TraverseRef s f a -> f a -> m ()
copyTraverse :: TraverseRef s f a -> f a -> m ()
copyTraverse (TraverseRef rs :: f (Ref s a)
rs) xs :: f a
xs = StateT [a] m () -> [a] -> m ()
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT ((Ref s a -> StateT [a] m ()) -> f (Ref s a) -> StateT [a] m ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
(a -> f b) -> t a -> f ()
traverse_ Ref s a -> StateT [a] m ()
forall (m :: * -> *) a.
(Mutable (PrimState m) a, PrimMonad m) =>
Ref (PrimState m) a -> StateT [a] m ()
go f (Ref s a)
rs) (f a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList f a
xs)
where
go :: Ref (PrimState m) a -> StateT [a] m ()
go r :: Ref (PrimState m) a
r = do
Maybe a
x <- ([a] -> (Maybe a, [a])) -> StateT [a] m (Maybe a)
forall (m :: * -> *) s a. Monad m => (s -> (a, s)) -> StateT s m a
state (([a] -> (Maybe a, [a])) -> StateT [a] m (Maybe a))
-> ([a] -> (Maybe a, [a])) -> StateT [a] m (Maybe a)
forall a b. (a -> b) -> a -> b
$ (Maybe a, [a])
-> ((a, [a]) -> (Maybe a, [a])) -> Maybe (a, [a]) -> (Maybe a, [a])
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Maybe a
forall a. Maybe a
Nothing, []) ((a -> Maybe a) -> (a, [a]) -> (Maybe a, [a])
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first a -> Maybe a
forall a. a -> Maybe a
Just) (Maybe (a, [a]) -> (Maybe a, [a]))
-> ([a] -> Maybe (a, [a])) -> [a] -> (Maybe a, [a])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> Maybe (a, [a])
forall a. [a] -> Maybe (a, [a])
uncons
m () -> StateT [a] m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT [a] m ()) -> m () -> StateT [a] m ()
forall a b. (a -> b) -> a -> b
$ (a -> m ()) -> Maybe a -> m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Ref (PrimState m) a -> a -> m ()
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> a -> m ()
copyRef Ref (PrimState m) a
r) Maybe a
x
moveTraverse
:: (Traversable f, Mutable s a, PrimMonad m, PrimState m ~ s)
=> TraverseRef s f a
-> TraverseRef s f a
-> m ()
moveTraverse :: TraverseRef s f a -> TraverseRef s f a -> m ()
moveTraverse (TraverseRef rs :: f (Ref s a)
rs) (TraverseRef vs :: f (Ref s a)
vs) = StateT [Ref s a] m () -> [Ref s a] -> m ()
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT ((Ref s a -> StateT [Ref s a] m ())
-> f (Ref s a) -> StateT [Ref s a] m ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
(a -> f b) -> t a -> f ()
traverse_ Ref s a -> StateT [Ref s a] m ()
forall (m :: * -> *) a.
(Mutable (PrimState m) a, PrimMonad m) =>
Ref (PrimState m) a -> StateT [Ref (PrimState m) a] m ()
go f (Ref s a)
rs) (f (Ref s a) -> [Ref s a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList f (Ref s a)
vs)
where
go :: Ref (PrimState m) a -> StateT [Ref (PrimState m) a] m ()
go r :: Ref (PrimState m) a
r = do
Maybe (Ref (PrimState m) a)
x <- ([Ref (PrimState m) a]
-> (Maybe (Ref (PrimState m) a), [Ref (PrimState m) a]))
-> StateT [Ref (PrimState m) a] m (Maybe (Ref (PrimState m) a))
forall (m :: * -> *) s a. Monad m => (s -> (a, s)) -> StateT s m a
state (([Ref (PrimState m) a]
-> (Maybe (Ref (PrimState m) a), [Ref (PrimState m) a]))
-> StateT [Ref (PrimState m) a] m (Maybe (Ref (PrimState m) a)))
-> ([Ref (PrimState m) a]
-> (Maybe (Ref (PrimState m) a), [Ref (PrimState m) a]))
-> StateT [Ref (PrimState m) a] m (Maybe (Ref (PrimState m) a))
forall a b. (a -> b) -> a -> b
$ (Maybe (Ref (PrimState m) a), [Ref (PrimState m) a])
-> ((Ref (PrimState m) a, [Ref (PrimState m) a])
-> (Maybe (Ref (PrimState m) a), [Ref (PrimState m) a]))
-> Maybe (Ref (PrimState m) a, [Ref (PrimState m) a])
-> (Maybe (Ref (PrimState m) a), [Ref (PrimState m) a])
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Maybe (Ref (PrimState m) a)
forall a. Maybe a
Nothing, []) ((Ref (PrimState m) a -> Maybe (Ref (PrimState m) a))
-> (Ref (PrimState m) a, [Ref (PrimState m) a])
-> (Maybe (Ref (PrimState m) a), [Ref (PrimState m) a])
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first Ref (PrimState m) a -> Maybe (Ref (PrimState m) a)
forall a. a -> Maybe a
Just) (Maybe (Ref (PrimState m) a, [Ref (PrimState m) a])
-> (Maybe (Ref (PrimState m) a), [Ref (PrimState m) a]))
-> ([Ref (PrimState m) a]
-> Maybe (Ref (PrimState m) a, [Ref (PrimState m) a]))
-> [Ref (PrimState m) a]
-> (Maybe (Ref (PrimState m) a), [Ref (PrimState m) a])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Ref (PrimState m) a]
-> Maybe (Ref (PrimState m) a, [Ref (PrimState m) a])
forall a. [a] -> Maybe (a, [a])
uncons
m () -> StateT [Ref (PrimState m) a] m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT [Ref (PrimState m) a] m ())
-> m () -> StateT [Ref (PrimState m) a] m ()
forall a b. (a -> b) -> a -> b
$ (Ref (PrimState m) a -> m ())
-> Maybe (Ref (PrimState m) a) -> m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Ref (PrimState m) a -> Ref (PrimState m) a -> m ()
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> Ref s a -> m ()
moveRef Ref (PrimState m) a
r) Maybe (Ref (PrimState m) a)
x
cloneTraverse :: (Traversable f, Mutable s a, PrimMonad m, PrimState m ~ s) => TraverseRef s f a -> m (TraverseRef s f a)
cloneTraverse :: TraverseRef s f a -> m (TraverseRef s f a)
cloneTraverse = (f (Ref s a) -> TraverseRef s f a)
-> m (f (Ref s a)) -> m (TraverseRef s f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap f (Ref s a) -> TraverseRef s f a
forall s (f :: * -> *) a. f (Ref s a) -> TraverseRef s f a
TraverseRef (m (f (Ref s a)) -> m (TraverseRef s f a))
-> (TraverseRef s f a -> m (f (Ref s a)))
-> TraverseRef s f a
-> m (TraverseRef s f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Ref s a -> m (Ref s a)) -> f (Ref s a) -> m (f (Ref s a))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Ref s a -> m (Ref s a)
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> m (Ref s a)
cloneRef (f (Ref s a) -> m (f (Ref s a)))
-> (TraverseRef s f a -> f (Ref s a))
-> TraverseRef s f a
-> m (f (Ref s a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TraverseRef s f a -> f (Ref s a)
forall s (f :: * -> *) a. TraverseRef s f a -> f (Ref s a)
getTraverseRef
unsafeThawTraverse :: (Traversable f, Mutable s a, PrimMonad m, PrimState m ~ s) => f a -> m (TraverseRef s f a)
unsafeThawTraverse :: f a -> m (TraverseRef s f a)
unsafeThawTraverse = (f (Ref s a) -> TraverseRef s f a)
-> m (f (Ref s a)) -> m (TraverseRef s f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap f (Ref s a) -> TraverseRef s f a
forall s (f :: * -> *) a. f (Ref s a) -> TraverseRef s f a
TraverseRef (m (f (Ref s a)) -> m (TraverseRef s f a))
-> (f a -> m (f (Ref s a))) -> f a -> m (TraverseRef s f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> m (Ref s a)) -> f a -> m (f (Ref s a))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> m (Ref s a)
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
a -> m (Ref s a)
unsafeThawRef
unsafeFreezeTraverse :: (Traversable f, Mutable s a, PrimMonad m, PrimState m ~ s) => TraverseRef s f a -> m (f a)
unsafeFreezeTraverse :: TraverseRef s f a -> m (f a)
unsafeFreezeTraverse = (Ref s a -> m a) -> f (Ref s a) -> m (f a)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Ref s a -> m a
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> m a
unsafeFreezeRef (f (Ref s a) -> m (f a))
-> (TraverseRef s f a -> f (Ref s a))
-> TraverseRef s f a
-> m (f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TraverseRef s f a -> f (Ref s a)
forall s (f :: * -> *) a. TraverseRef s f a -> f (Ref s a)
getTraverseRef
newtype CoerceRef s b a = CoerceRef { CoerceRef s b a -> Ref s a
getCoerceRef :: Ref s a }
deriving instance Eq (Ref s a) => Eq (CoerceRef s b a)
deriving instance Ord (Ref s a) => Ord (CoerceRef s b a)
instance X.IsoHKD (CoerceRef s b) a where
type HKD (CoerceRef s b) a = Ref s a
unHKD :: HKD (CoerceRef s b) a -> CoerceRef s b a
unHKD = HKD (CoerceRef s b) a -> CoerceRef s b a
forall k s (b :: k) a. Ref s a -> CoerceRef s b a
CoerceRef
toHKD :: CoerceRef s b a -> HKD (CoerceRef s b) a
toHKD = CoerceRef s b a -> HKD (CoerceRef s b) a
forall s k (b :: k) a. CoerceRef s b a -> Ref s a
getCoerceRef
thawCoerce :: (Coercible b a, Mutable s a, PrimMonad m, PrimState m ~ s) => b -> m (CoerceRef s b a)
thawCoerce :: b -> m (CoerceRef s b a)
thawCoerce = (Ref s a -> CoerceRef s b a) -> m (Ref s a) -> m (CoerceRef s b a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ref s a -> CoerceRef s b a
forall k s (b :: k) a. Ref s a -> CoerceRef s b a
CoerceRef (m (Ref s a) -> m (CoerceRef s b a))
-> (b -> m (Ref s a)) -> b -> m (CoerceRef s b a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m (Ref s a)
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
a -> m (Ref s a)
thawRef (a -> m (Ref s a)) -> (b -> a) -> b -> m (Ref s a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> a
forall a b. Coercible a b => a -> b
coerce
freezeCoerce :: (Coercible b a, Mutable s a, PrimMonad m, PrimState m ~ s) => CoerceRef s b a -> m b
freezeCoerce :: CoerceRef s b a -> m b
freezeCoerce = (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
forall a b. Coercible a b => a -> b
coerce (m a -> m b) -> (CoerceRef s b a -> m a) -> CoerceRef s b a -> m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref s a -> m a
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> m a
freezeRef (Ref s a -> m a)
-> (CoerceRef s b a -> Ref s a) -> CoerceRef s b a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CoerceRef s b a -> Ref s a
forall s k (b :: k) a. CoerceRef s b a -> Ref s a
getCoerceRef
copyCoerce :: (Coercible b a, Mutable s a, PrimMonad m, PrimState m ~ s) => CoerceRef s b a -> b -> m ()
copyCoerce :: CoerceRef s b a -> b -> m ()
copyCoerce (CoerceRef r :: Ref s a
r) = Ref s a -> a -> m ()
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> a -> m ()
copyRef Ref s a
r (a -> m ()) -> (b -> a) -> b -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> a
forall a b. Coercible a b => a -> b
coerce
moveCoerce :: (Mutable s a, PrimMonad m, PrimState m ~ s) => CoerceRef s b a -> CoerceRef s b a -> m ()
moveCoerce :: CoerceRef s b a -> CoerceRef s b a -> m ()
moveCoerce (CoerceRef r :: Ref s a
r) (CoerceRef s :: Ref s a
s) = Ref s a -> Ref s a -> m ()
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> Ref s a -> m ()
moveRef Ref s a
r Ref s a
s
cloneCoerce :: (Mutable s a, PrimMonad m, PrimState m ~ s) => CoerceRef s b a -> m (CoerceRef s b a)
cloneCoerce :: CoerceRef s b a -> m (CoerceRef s b a)
cloneCoerce = (Ref s a -> CoerceRef s b a) -> m (Ref s a) -> m (CoerceRef s b a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ref s a -> CoerceRef s b a
forall k s (b :: k) a. Ref s a -> CoerceRef s b a
CoerceRef (m (Ref s a) -> m (CoerceRef s b a))
-> (CoerceRef s b a -> m (Ref s a))
-> CoerceRef s b a
-> m (CoerceRef s b a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref s a -> m (Ref s a)
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> m (Ref s a)
cloneRef (Ref s a -> m (Ref s a))
-> (CoerceRef s b a -> Ref s a) -> CoerceRef s b a -> m (Ref s a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CoerceRef s b a -> Ref s a
forall s k (b :: k) a. CoerceRef s b a -> Ref s a
getCoerceRef
unsafeThawCoerce :: (Coercible b a, Mutable s a, PrimMonad m, PrimState m ~ s) => b -> m (CoerceRef s b a)
unsafeThawCoerce :: b -> m (CoerceRef s b a)
unsafeThawCoerce = (Ref s a -> CoerceRef s b a) -> m (Ref s a) -> m (CoerceRef s b a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ref s a -> CoerceRef s b a
forall k s (b :: k) a. Ref s a -> CoerceRef s b a
CoerceRef (m (Ref s a) -> m (CoerceRef s b a))
-> (b -> m (Ref s a)) -> b -> m (CoerceRef s b a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m (Ref s a)
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
a -> m (Ref s a)
unsafeThawRef (a -> m (Ref s a)) -> (b -> a) -> b -> m (Ref s a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> a
forall a b. Coercible a b => a -> b
coerce
unsafeFreezeCoerce :: (Coercible b a, Mutable s a, PrimMonad m, PrimState m ~ s) => CoerceRef s b a -> m b
unsafeFreezeCoerce :: CoerceRef s b a -> m b
unsafeFreezeCoerce = (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
forall a b. Coercible a b => a -> b
coerce (m a -> m b) -> (CoerceRef s b a -> m a) -> CoerceRef s b a -> m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref s a -> m a
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> m a
unsafeFreezeRef (Ref s a -> m a)
-> (CoerceRef s b a -> Ref s a) -> CoerceRef s b a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CoerceRef s b a -> Ref s a
forall s k (b :: k) a. CoerceRef s b a -> Ref s a
getCoerceRef
newtype ImmutableRef s a = ImmutableRef { ImmutableRef s a -> a
getImmutableRef :: a }
instance X.IsoHKD (ImmutableRef s) a where
type HKD (ImmutableRef s) a = a
unHKD :: HKD (ImmutableRef s) a -> ImmutableRef s a
unHKD = HKD (ImmutableRef s) a -> ImmutableRef s a
forall k (s :: k) a. a -> ImmutableRef s a
ImmutableRef
toHKD :: ImmutableRef s a -> HKD (ImmutableRef s) a
toHKD = ImmutableRef s a -> HKD (ImmutableRef s) a
forall k (s :: k) a. ImmutableRef s a -> a
getImmutableRef
thawImmutable :: Applicative m => a -> m (ImmutableRef s a)
thawImmutable :: a -> m (ImmutableRef s a)
thawImmutable = ImmutableRef s a -> m (ImmutableRef s a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ImmutableRef s a -> m (ImmutableRef s a))
-> (a -> ImmutableRef s a) -> a -> m (ImmutableRef s a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> ImmutableRef s a
forall k (s :: k) a. a -> ImmutableRef s a
ImmutableRef
freezeImmutable :: Applicative m => ImmutableRef s a -> m a
freezeImmutable :: ImmutableRef s a -> m a
freezeImmutable = a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> m a) -> (ImmutableRef s a -> a) -> ImmutableRef s a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ImmutableRef s a -> a
forall k (s :: k) a. ImmutableRef s a -> a
getImmutableRef
copyImmutable :: Applicative m => ImmutableRef s a -> a -> m ()
copyImmutable :: ImmutableRef s a -> a -> m ()
copyImmutable _ _ = () -> m ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
moveImmutable :: Applicative m => ImmutableRef s a -> ImmutableRef s a -> m ()
moveImmutable :: ImmutableRef s a -> ImmutableRef s a -> m ()
moveImmutable _ _ = () -> m ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
cloneImmutable :: Applicative m => ImmutableRef s a -> m (ImmutableRef s a)
cloneImmutable :: ImmutableRef s a -> m (ImmutableRef s a)
cloneImmutable = ImmutableRef s a -> m (ImmutableRef s a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure
class GMutable s (f :: Type -> Type) where
type GRef_ s f = (u :: Type -> Type) | u -> f
gThawRef_ :: (PrimMonad m, PrimState m ~ s) => f a -> m (GRef_ s f a)
gFreezeRef_ :: (PrimMonad m, PrimState m ~ s) => GRef_ s f a -> m (f a)
gCopyRef_ :: (PrimMonad m, PrimState m ~ s) => GRef_ s f a -> f a -> m ()
gMoveRef_ :: (PrimMonad m, PrimState m ~ s) => GRef_ s f a -> GRef_ s f a -> m ()
gCloneRef_ :: (PrimMonad m, PrimState m ~ s) => GRef_ s f a -> m (GRef_ s f a)
gUnsafeThawRef_ :: (PrimMonad m, PrimState m ~ s) => f a -> m (GRef_ s f a)
gUnsafeFreezeRef_ :: (PrimMonad m, PrimState m ~ s) => GRef_ s f a -> m (f a)
instance Mutable s c => GMutable s (K1 i c) where
type GRef_ s (K1 i c) = K1 i (Ref s c)
gThawRef_ :: K1 i c a -> m (GRef_ s (K1 i c) a)
gThawRef_ = (Ref s c -> K1 i (Ref s c) a)
-> m (Ref s c) -> m (K1 i (Ref s c) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ref s c -> K1 i (Ref s c) a
forall k i c (p :: k). c -> K1 i c p
K1 (m (Ref s c) -> m (K1 i (Ref s c) a))
-> (K1 i c a -> m (Ref s c)) -> K1 i c a -> m (K1 i (Ref s c) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m (Ref s c)
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
a -> m (Ref s a)
thawRef (c -> m (Ref s c)) -> (K1 i c a -> c) -> K1 i c a -> m (Ref s c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. K1 i c a -> c
forall i c k (p :: k). K1 i c p -> c
unK1
gFreezeRef_ :: GRef_ s (K1 i c) a -> m (K1 i c a)
gFreezeRef_ = (c -> K1 i c a) -> m c -> m (K1 i c a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap c -> K1 i c a
forall k i c (p :: k). c -> K1 i c p
K1 (m c -> m (K1 i c a))
-> (K1 i (Ref s c) a -> m c) -> K1 i (Ref s c) a -> m (K1 i c a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref s c -> m c
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> m a
freezeRef (Ref s c -> m c)
-> (K1 i (Ref s c) a -> Ref s c) -> K1 i (Ref s c) a -> m c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. K1 i (Ref s c) a -> Ref s c
forall i c k (p :: k). K1 i c p -> c
unK1
gCopyRef_ :: GRef_ s (K1 i c) a -> K1 i c a -> m ()
gCopyRef_ (K1 v) (K1 x :: c
x) = Ref s c -> c -> m ()
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> a -> m ()
copyRef Ref s c
v c
x
gMoveRef_ :: GRef_ s (K1 i c) a -> GRef_ s (K1 i c) a -> m ()
gMoveRef_ (K1 v) (K1 u) = Ref s c -> Ref s c -> m ()
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> Ref s a -> m ()
moveRef Ref s c
v Ref s c
u
gCloneRef_ :: GRef_ s (K1 i c) a -> m (GRef_ s (K1 i c) a)
gCloneRef_ = (Ref s c -> K1 i (Ref s c) a)
-> m (Ref s c) -> m (K1 i (Ref s c) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ref s c -> K1 i (Ref s c) a
forall k i c (p :: k). c -> K1 i c p
K1 (m (Ref s c) -> m (K1 i (Ref s c) a))
-> (K1 i (Ref s c) a -> m (Ref s c))
-> K1 i (Ref s c) a
-> m (K1 i (Ref s c) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref s c -> m (Ref s c)
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> m (Ref s a)
cloneRef (Ref s c -> m (Ref s c))
-> (K1 i (Ref s c) a -> Ref s c) -> K1 i (Ref s c) a -> m (Ref s c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. K1 i (Ref s c) a -> Ref s c
forall i c k (p :: k). K1 i c p -> c
unK1
gUnsafeThawRef_ :: K1 i c a -> m (GRef_ s (K1 i c) a)
gUnsafeThawRef_ = (Ref s c -> K1 i (Ref s c) a)
-> m (Ref s c) -> m (K1 i (Ref s c) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ref s c -> K1 i (Ref s c) a
forall k i c (p :: k). c -> K1 i c p
K1 (m (Ref s c) -> m (K1 i (Ref s c) a))
-> (K1 i c a -> m (Ref s c)) -> K1 i c a -> m (K1 i (Ref s c) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m (Ref s c)
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
a -> m (Ref s a)
unsafeThawRef (c -> m (Ref s c)) -> (K1 i c a -> c) -> K1 i c a -> m (Ref s c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. K1 i c a -> c
forall i c k (p :: k). K1 i c p -> c
unK1
gUnsafeFreezeRef_ :: GRef_ s (K1 i c) a -> m (K1 i c a)
gUnsafeFreezeRef_ = (c -> K1 i c a) -> m c -> m (K1 i c a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap c -> K1 i c a
forall k i c (p :: k). c -> K1 i c p
K1 (m c -> m (K1 i c a))
-> (K1 i (Ref s c) a -> m c) -> K1 i (Ref s c) a -> m (K1 i c a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref s c -> m c
forall s a (m :: * -> *).
(Mutable s a, PrimMonad m, PrimState m ~ s) =>
Ref s a -> m a
unsafeFreezeRef (Ref s c -> m c)
-> (K1 i (Ref s c) a -> Ref s c) -> K1 i (Ref s c) a -> m c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. K1 i (Ref s c) a -> Ref s c
forall i c k (p :: k). K1 i c p -> c
unK1
instance GMutable s U1 where
type GRef_ s U1 = U1
gThawRef_ :: U1 a -> m (GRef_ s U1 a)
gThawRef_ _ = U1 a -> m (U1 a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure U1 a
forall k (p :: k). U1 p
U1
gFreezeRef_ :: GRef_ s U1 a -> m (U1 a)
gFreezeRef_ _ = U1 a -> m (U1 a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure U1 a
forall k (p :: k). U1 p
U1
gCopyRef_ :: GRef_ s U1 a -> U1 a -> m ()
gCopyRef_ _ _ = () -> m ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
gMoveRef_ :: GRef_ s U1 a -> GRef_ s U1 a -> m ()
gMoveRef_ _ _ = () -> m ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
gCloneRef_ :: GRef_ s U1 a -> m (GRef_ s U1 a)
gCloneRef_ _ = U1 a -> m (U1 a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure U1 a
forall k (p :: k). U1 p
U1
gUnsafeThawRef_ :: U1 a -> m (GRef_ s U1 a)
gUnsafeThawRef_ _ = U1 a -> m (U1 a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure U1 a
forall k (p :: k). U1 p
U1
gUnsafeFreezeRef_ :: GRef_ s U1 a -> m (U1 a)
gUnsafeFreezeRef_ _ = U1 a -> m (U1 a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure U1 a
forall k (p :: k). U1 p
U1
instance GMutable s V1 where
type GRef_ s V1 = V1
gThawRef_ :: V1 a -> m (GRef_ s V1 a)
gThawRef_ = \case {}
gFreezeRef_ :: GRef_ s V1 a -> m (V1 a)
gFreezeRef_ = \case {}
gCopyRef_ :: GRef_ s V1 a -> V1 a -> m ()
gCopyRef_ = \case {}
gMoveRef_ :: GRef_ s V1 a -> GRef_ s V1 a -> m ()
gMoveRef_ = \case {}
gCloneRef_ :: GRef_ s V1 a -> m (GRef_ s V1 a)
gCloneRef_ = \case {}
gUnsafeThawRef_ :: V1 a -> m (GRef_ s V1 a)
gUnsafeThawRef_ = \case {}
gUnsafeFreezeRef_ :: GRef_ s V1 a -> m (V1 a)
gUnsafeFreezeRef_ = \case {}
instance (GMutable s f, GMutable s g) => GMutable s (f :*: g) where
type GRef_ s (f :*: g) = GRef_ s f :*: GRef_ s g
gThawRef_ :: (:*:) f g a -> m (GRef_ s (f :*: g) a)
gThawRef_ (x :: f a
x :*: y :: g a
y) = GRef_ s f a -> GRef_ s g a -> (:*:) (GRef_ s f) (GRef_ s g) a
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
(:*:) (GRef_ s f a -> GRef_ s g a -> (:*:) (GRef_ s f) (GRef_ s g) a)
-> m (GRef_ s f a)
-> m (GRef_ s g a -> (:*:) (GRef_ s f) (GRef_ s g) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f a -> m (GRef_ s f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gThawRef_ f a
x m (GRef_ s g a -> (:*:) (GRef_ s f) (GRef_ s g) a)
-> m (GRef_ s g a) -> m ((:*:) (GRef_ s f) (GRef_ s g) a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> g a -> m (GRef_ s g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gThawRef_ g a
y
gFreezeRef_ :: GRef_ s (f :*: g) a -> m ((:*:) f g a)
gFreezeRef_ (v :*: u) = f a -> g a -> (:*:) f g a
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
(:*:) (f a -> g a -> (:*:) f g a) -> m (f a) -> m (g a -> (:*:) f g a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GRef_ s f a -> m (f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gFreezeRef_ GRef_ s f a
v m (g a -> (:*:) f g a) -> m (g a) -> m ((:*:) f g a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> GRef_ s g a -> m (g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gFreezeRef_ GRef_ s g a
u
gCopyRef_ :: GRef_ s (f :*: g) a -> (:*:) f g a -> m ()
gCopyRef_ (v :*: u) (x :: f a
x :*: y :: g a
y) = GRef_ s f a -> f a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> f a -> m ()
gCopyRef_ GRef_ s f a
v f a
x m () -> m () -> m ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GRef_ s g a -> g a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> f a -> m ()
gCopyRef_ GRef_ s g a
u g a
y
gMoveRef_ :: GRef_ s (f :*: g) a -> GRef_ s (f :*: g) a -> m ()
gMoveRef_ (v :*: u) (v' :*: u') = GRef_ s f a -> GRef_ s f a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> GRef_ s f a -> m ()
gMoveRef_ GRef_ s f a
v GRef_ s f a
v' m () -> m () -> m ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GRef_ s g a -> GRef_ s g a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> GRef_ s f a -> m ()
gMoveRef_ GRef_ s g a
u GRef_ s g a
u'
gCloneRef_ :: GRef_ s (f :*: g) a -> m (GRef_ s (f :*: g) a)
gCloneRef_ (v :*: u) = GRef_ s f a -> GRef_ s g a -> (:*:) (GRef_ s f) (GRef_ s g) a
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
(:*:) (GRef_ s f a -> GRef_ s g a -> (:*:) (GRef_ s f) (GRef_ s g) a)
-> m (GRef_ s f a)
-> m (GRef_ s g a -> (:*:) (GRef_ s f) (GRef_ s g) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GRef_ s f a -> m (GRef_ s f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (GRef_ s f a)
gCloneRef_ GRef_ s f a
v m (GRef_ s g a -> (:*:) (GRef_ s f) (GRef_ s g) a)
-> m (GRef_ s g a) -> m ((:*:) (GRef_ s f) (GRef_ s g) a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> GRef_ s g a -> m (GRef_ s g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (GRef_ s f a)
gCloneRef_ GRef_ s g a
u
gUnsafeThawRef_ :: (:*:) f g a -> m (GRef_ s (f :*: g) a)
gUnsafeThawRef_ (x :: f a
x :*: y :: g a
y) = GRef_ s f a -> GRef_ s g a -> (:*:) (GRef_ s f) (GRef_ s g) a
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
(:*:) (GRef_ s f a -> GRef_ s g a -> (:*:) (GRef_ s f) (GRef_ s g) a)
-> m (GRef_ s f a)
-> m (GRef_ s g a -> (:*:) (GRef_ s f) (GRef_ s g) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f a -> m (GRef_ s f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gUnsafeThawRef_ f a
x m (GRef_ s g a -> (:*:) (GRef_ s f) (GRef_ s g) a)
-> m (GRef_ s g a) -> m ((:*:) (GRef_ s f) (GRef_ s g) a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> g a -> m (GRef_ s g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gUnsafeThawRef_ g a
y
gUnsafeFreezeRef_ :: GRef_ s (f :*: g) a -> m ((:*:) f g a)
gUnsafeFreezeRef_ (v :*: u) = f a -> g a -> (:*:) f g a
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
(:*:) (f a -> g a -> (:*:) f g a) -> m (f a) -> m (g a -> (:*:) f g a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GRef_ s f a -> m (f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gUnsafeFreezeRef_ GRef_ s f a
v m (g a -> (:*:) f g a) -> m (g a) -> m ((:*:) f g a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> GRef_ s g a -> m (g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gUnsafeFreezeRef_ GRef_ s g a
u
instance GMutable s f => GMutable s (M1 i c f) where
type GRef_ s (M1 i c f) = M1 i c (GRef_ s f)
gThawRef_ :: M1 i c f a -> m (GRef_ s (M1 i c f) a)
gThawRef_ = (GRef_ s f a -> M1 i c (GRef_ s f) a)
-> m (GRef_ s f a) -> m (M1 i c (GRef_ s f) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap GRef_ s f a -> M1 i c (GRef_ s f) a
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
M1 (m (GRef_ s f a) -> m (M1 i c (GRef_ s f) a))
-> (M1 i c f a -> m (GRef_ s f a))
-> M1 i c f a
-> m (M1 i c (GRef_ s f) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> m (GRef_ s f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gThawRef_ (f a -> m (GRef_ s f a))
-> (M1 i c f a -> f a) -> M1 i c f a -> m (GRef_ s f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. M1 i c f a -> f a
forall i (c :: Meta) k (f :: k -> *) (p :: k). M1 i c f p -> f p
unM1
gFreezeRef_ :: GRef_ s (M1 i c f) a -> m (M1 i c f a)
gFreezeRef_ = (f a -> M1 i c f a) -> m (f a) -> m (M1 i c f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap f a -> M1 i c f a
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
M1 (m (f a) -> m (M1 i c f a))
-> (M1 i c (GRef_ s f) a -> m (f a))
-> M1 i c (GRef_ s f) a
-> m (M1 i c f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s f a -> m (f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gFreezeRef_ (GRef_ s f a -> m (f a))
-> (M1 i c (GRef_ s f) a -> GRef_ s f a)
-> M1 i c (GRef_ s f) a
-> m (f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. M1 i c (GRef_ s f) a -> GRef_ s f a
forall i (c :: Meta) k (f :: k -> *) (p :: k). M1 i c f p -> f p
unM1
gCopyRef_ :: GRef_ s (M1 i c f) a -> M1 i c f a -> m ()
gCopyRef_ (M1 v) (M1 x :: f a
x) = GRef_ s f a -> f a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> f a -> m ()
gCopyRef_ GRef_ s f a
v f a
x
gMoveRef_ :: GRef_ s (M1 i c f) a -> GRef_ s (M1 i c f) a -> m ()
gMoveRef_ (M1 v) (M1 u) = GRef_ s f a -> GRef_ s f a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> GRef_ s f a -> m ()
gMoveRef_ GRef_ s f a
v GRef_ s f a
u
gCloneRef_ :: GRef_ s (M1 i c f) a -> m (GRef_ s (M1 i c f) a)
gCloneRef_ (M1 v) = GRef_ s f a -> M1 i c (GRef_ s f) a
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
M1 (GRef_ s f a -> M1 i c (GRef_ s f) a)
-> m (GRef_ s f a) -> m (M1 i c (GRef_ s f) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GRef_ s f a -> m (GRef_ s f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (GRef_ s f a)
gCloneRef_ GRef_ s f a
v
gUnsafeThawRef_ :: M1 i c f a -> m (GRef_ s (M1 i c f) a)
gUnsafeThawRef_ = (GRef_ s f a -> M1 i c (GRef_ s f) a)
-> m (GRef_ s f a) -> m (M1 i c (GRef_ s f) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap GRef_ s f a -> M1 i c (GRef_ s f) a
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
M1 (m (GRef_ s f a) -> m (M1 i c (GRef_ s f) a))
-> (M1 i c f a -> m (GRef_ s f a))
-> M1 i c f a
-> m (M1 i c (GRef_ s f) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> m (GRef_ s f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gUnsafeThawRef_ (f a -> m (GRef_ s f a))
-> (M1 i c f a -> f a) -> M1 i c f a -> m (GRef_ s f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. M1 i c f a -> f a
forall i (c :: Meta) k (f :: k -> *) (p :: k). M1 i c f p -> f p
unM1
gUnsafeFreezeRef_ :: GRef_ s (M1 i c f) a -> m (M1 i c f a)
gUnsafeFreezeRef_ = (f a -> M1 i c f a) -> m (f a) -> m (M1 i c f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap f a -> M1 i c f a
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
M1 (m (f a) -> m (M1 i c f a))
-> (M1 i c (GRef_ s f) a -> m (f a))
-> M1 i c (GRef_ s f) a
-> m (M1 i c f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s f a -> m (f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gUnsafeFreezeRef_ (GRef_ s f a -> m (f a))
-> (M1 i c (GRef_ s f) a -> GRef_ s f a)
-> M1 i c (GRef_ s f) a
-> m (f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. M1 i c (GRef_ s f) a -> GRef_ s f a
forall i (c :: Meta) k (f :: k -> *) (p :: k). M1 i c f p -> f p
unM1
newtype MutSumF s f g a = MutSumF { MutSumF s f g a -> MutVar s ((:+:) f g a)
getMutSumF :: MutVar s ((f :+: g) a) }
instance (GMutable s f, GMutable s g) => GMutable s (f :+: g) where
type GRef_ s (f :+: g) = MutSumF s (GRef_ s f) (GRef_ s g)
gThawRef_ :: (:+:) f g a -> m (GRef_ s (f :+: g) a)
gThawRef_ = \case
L1 x :: f a
x -> (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
-> MutSumF s (GRef_ s f) (GRef_ s g) a)
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
-> MutSumF s (GRef_ s f) (GRef_ s g) a
forall k s (f :: k -> *) (g :: k -> *) (a :: k).
MutVar s ((:+:) f g a) -> MutSumF s f g a
MutSumF (m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a))
-> (GRef_ s f a -> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)))
-> GRef_ s f a
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:+:) (GRef_ s f) (GRef_ s g) a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
forall (m :: * -> *) a.
PrimMonad m =>
a -> m (MutVar (PrimState m) a)
newMutVar ((:+:) (GRef_ s f) (GRef_ s g) a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)))
-> (GRef_ s f a -> (:+:) (GRef_ s f) (GRef_ s g) a)
-> GRef_ s f a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s f a -> (:+:) (GRef_ s f) (GRef_ s g) a
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
L1 (GRef_ s f a -> m (MutSumF s (GRef_ s f) (GRef_ s g) a))
-> m (GRef_ s f a) -> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< f a -> m (GRef_ s f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gThawRef_ f a
x
R1 x :: g a
x -> (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
-> MutSumF s (GRef_ s f) (GRef_ s g) a)
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
-> MutSumF s (GRef_ s f) (GRef_ s g) a
forall k s (f :: k -> *) (g :: k -> *) (a :: k).
MutVar s ((:+:) f g a) -> MutSumF s f g a
MutSumF (m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a))
-> (GRef_ s g a -> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)))
-> GRef_ s g a
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:+:) (GRef_ s f) (GRef_ s g) a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
forall (m :: * -> *) a.
PrimMonad m =>
a -> m (MutVar (PrimState m) a)
newMutVar ((:+:) (GRef_ s f) (GRef_ s g) a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)))
-> (GRef_ s g a -> (:+:) (GRef_ s f) (GRef_ s g) a)
-> GRef_ s g a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s g a -> (:+:) (GRef_ s f) (GRef_ s g) a
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
R1 (GRef_ s g a -> m (MutSumF s (GRef_ s f) (GRef_ s g) a))
-> m (GRef_ s g a) -> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< g a -> m (GRef_ s g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gThawRef_ g a
x
gFreezeRef_ :: GRef_ s (f :+: g) a -> m ((:+:) f g a)
gFreezeRef_ (MutSumF r) = MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
-> m ((:+:) (GRef_ s f) (GRef_ s g) a)
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> m a
readMutVar MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
r m ((:+:) (GRef_ s f) (GRef_ s g) a)
-> ((:+:) (GRef_ s f) (GRef_ s g) a -> m ((:+:) f g a))
-> m ((:+:) f g a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
L1 v :: GRef_ s f a
v -> f a -> (:+:) f g a
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
L1 (f a -> (:+:) f g a) -> m (f a) -> m ((:+:) f g a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GRef_ s f a -> m (f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gFreezeRef_ GRef_ s f a
v
R1 u :: GRef_ s g a
u -> g a -> (:+:) f g a
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
R1 (g a -> (:+:) f g a) -> m (g a) -> m ((:+:) f g a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GRef_ s g a -> m (g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gFreezeRef_ GRef_ s g a
u
gCopyRef_ :: GRef_ s (f :+: g) a -> (:+:) f g a -> m ()
gCopyRef_ (MutSumF r) xy :: (:+:) f g a
xy = MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
-> m ((:+:) (GRef_ s f) (GRef_ s g) a)
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> m a
readMutVar MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
r m ((:+:) (GRef_ s f) (GRef_ s g) a)
-> ((:+:) (GRef_ s f) (GRef_ s g) a -> m ()) -> m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
L1 v :: GRef_ s f a
v -> case (:+:) f g a
xy of
L1 x :: f a
x -> GRef_ s f a -> f a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> f a -> m ()
gCopyRef_ GRef_ s f a
v f a
x
R1 y :: g a
y -> MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
-> (:+:) (GRef_ s f) (GRef_ s g) a -> m ()
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> a -> m ()
writeMutVar MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
r ((:+:) (GRef_ s f) (GRef_ s g) a -> m ())
-> (GRef_ s g a -> (:+:) (GRef_ s f) (GRef_ s g) a)
-> GRef_ s g a
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s g a -> (:+:) (GRef_ s f) (GRef_ s g) a
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
R1 (GRef_ s g a -> m ()) -> m (GRef_ s g a) -> m ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< g a -> m (GRef_ s g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gThawRef_ g a
y
R1 u :: GRef_ s g a
u -> case (:+:) f g a
xy of
L1 x :: f a
x -> MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
-> (:+:) (GRef_ s f) (GRef_ s g) a -> m ()
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> a -> m ()
writeMutVar MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
r ((:+:) (GRef_ s f) (GRef_ s g) a -> m ())
-> (GRef_ s f a -> (:+:) (GRef_ s f) (GRef_ s g) a)
-> GRef_ s f a
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s f a -> (:+:) (GRef_ s f) (GRef_ s g) a
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
L1 (GRef_ s f a -> m ()) -> m (GRef_ s f a) -> m ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< f a -> m (GRef_ s f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gThawRef_ f a
x
R1 y :: g a
y -> GRef_ s g a -> g a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> f a -> m ()
gCopyRef_ GRef_ s g a
u g a
y
gMoveRef_ :: GRef_ s (f :+: g) a -> GRef_ s (f :+: g) a -> m ()
gMoveRef_ (MutSumF u) (MutSumF v) = MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
-> m ((:+:) (GRef_ s f) (GRef_ s g) a)
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> m a
readMutVar MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
v m ((:+:) (GRef_ s f) (GRef_ s g) a)
-> ((:+:) (GRef_ s f) (GRef_ s g) a -> m ()) -> m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
L1 vl :: GRef_ s f a
vl -> MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
-> m ((:+:) (GRef_ s f) (GRef_ s g) a)
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> m a
readMutVar MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
u m ((:+:) (GRef_ s f) (GRef_ s g) a)
-> ((:+:) (GRef_ s f) (GRef_ s g) a -> m ()) -> m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
L1 ul :: GRef_ s f a
ul -> GRef_ s f a -> GRef_ s f a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> GRef_ s f a -> m ()
gMoveRef_ GRef_ s f a
ul GRef_ s f a
vl
R1 _ -> MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
-> (:+:) (GRef_ s f) (GRef_ s g) a -> m ()
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> a -> m ()
writeMutVar MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
u ((:+:) (GRef_ s f) (GRef_ s g) a -> m ())
-> (GRef_ s f a -> (:+:) (GRef_ s f) (GRef_ s g) a)
-> GRef_ s f a
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s f a -> (:+:) (GRef_ s f) (GRef_ s g) a
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
L1 (GRef_ s f a -> m ()) -> m (GRef_ s f a) -> m ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< GRef_ s f a -> m (GRef_ s f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (GRef_ s f a)
gCloneRef_ GRef_ s f a
vl
R1 vr :: GRef_ s g a
vr -> MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
-> m ((:+:) (GRef_ s f) (GRef_ s g) a)
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> m a
readMutVar MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
u m ((:+:) (GRef_ s f) (GRef_ s g) a)
-> ((:+:) (GRef_ s f) (GRef_ s g) a -> m ()) -> m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
L1 _ -> MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
-> (:+:) (GRef_ s f) (GRef_ s g) a -> m ()
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> a -> m ()
writeMutVar MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
u ((:+:) (GRef_ s f) (GRef_ s g) a -> m ())
-> (GRef_ s g a -> (:+:) (GRef_ s f) (GRef_ s g) a)
-> GRef_ s g a
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s g a -> (:+:) (GRef_ s f) (GRef_ s g) a
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
R1 (GRef_ s g a -> m ()) -> m (GRef_ s g a) -> m ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< GRef_ s g a -> m (GRef_ s g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (GRef_ s f a)
gCloneRef_ GRef_ s g a
vr
R1 ur :: GRef_ s g a
ur -> GRef_ s g a -> GRef_ s g a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> GRef_ s f a -> m ()
gMoveRef_ GRef_ s g a
ur GRef_ s g a
vr
gCloneRef_ :: GRef_ s (f :+: g) a -> m (GRef_ s (f :+: g) a)
gCloneRef_ (MutSumF v) = MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
-> m ((:+:) (GRef_ s f) (GRef_ s g) a)
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> m a
readMutVar MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
v m ((:+:) (GRef_ s f) (GRef_ s g) a)
-> ((:+:) (GRef_ s f) (GRef_ s g) a
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a))
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
L1 u :: GRef_ s f a
u -> (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
-> MutSumF s (GRef_ s f) (GRef_ s g) a)
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
-> MutSumF s (GRef_ s f) (GRef_ s g) a
forall k s (f :: k -> *) (g :: k -> *) (a :: k).
MutVar s ((:+:) f g a) -> MutSumF s f g a
MutSumF (m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a))
-> (GRef_ s f a -> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)))
-> GRef_ s f a
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:+:) (GRef_ s f) (GRef_ s g) a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
forall (m :: * -> *) a.
PrimMonad m =>
a -> m (MutVar (PrimState m) a)
newMutVar ((:+:) (GRef_ s f) (GRef_ s g) a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)))
-> (GRef_ s f a -> (:+:) (GRef_ s f) (GRef_ s g) a)
-> GRef_ s f a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s f a -> (:+:) (GRef_ s f) (GRef_ s g) a
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
L1 (GRef_ s f a -> m (MutSumF s (GRef_ s f) (GRef_ s g) a))
-> m (GRef_ s f a) -> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< GRef_ s f a -> m (GRef_ s f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (GRef_ s f a)
gCloneRef_ GRef_ s f a
u
R1 u :: GRef_ s g a
u -> (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
-> MutSumF s (GRef_ s f) (GRef_ s g) a)
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
-> MutSumF s (GRef_ s f) (GRef_ s g) a
forall k s (f :: k -> *) (g :: k -> *) (a :: k).
MutVar s ((:+:) f g a) -> MutSumF s f g a
MutSumF (m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a))
-> (GRef_ s g a -> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)))
-> GRef_ s g a
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:+:) (GRef_ s f) (GRef_ s g) a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
forall (m :: * -> *) a.
PrimMonad m =>
a -> m (MutVar (PrimState m) a)
newMutVar ((:+:) (GRef_ s f) (GRef_ s g) a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)))
-> (GRef_ s g a -> (:+:) (GRef_ s f) (GRef_ s g) a)
-> GRef_ s g a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s g a -> (:+:) (GRef_ s f) (GRef_ s g) a
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
R1 (GRef_ s g a -> m (MutSumF s (GRef_ s f) (GRef_ s g) a))
-> m (GRef_ s g a) -> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< GRef_ s g a -> m (GRef_ s g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (GRef_ s f a)
gCloneRef_ GRef_ s g a
u
gUnsafeThawRef_ :: (:+:) f g a -> m (GRef_ s (f :+: g) a)
gUnsafeThawRef_ = \case
L1 x :: f a
x -> (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
-> MutSumF s (GRef_ s f) (GRef_ s g) a)
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
-> MutSumF s (GRef_ s f) (GRef_ s g) a
forall k s (f :: k -> *) (g :: k -> *) (a :: k).
MutVar s ((:+:) f g a) -> MutSumF s f g a
MutSumF (m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a))
-> (GRef_ s f a -> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)))
-> GRef_ s f a
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:+:) (GRef_ s f) (GRef_ s g) a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
forall (m :: * -> *) a.
PrimMonad m =>
a -> m (MutVar (PrimState m) a)
newMutVar ((:+:) (GRef_ s f) (GRef_ s g) a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)))
-> (GRef_ s f a -> (:+:) (GRef_ s f) (GRef_ s g) a)
-> GRef_ s f a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s f a -> (:+:) (GRef_ s f) (GRef_ s g) a
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
L1 (GRef_ s f a -> m (MutSumF s (GRef_ s f) (GRef_ s g) a))
-> m (GRef_ s f a) -> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< f a -> m (GRef_ s f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gUnsafeThawRef_ f a
x
R1 x :: g a
x -> (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
-> MutSumF s (GRef_ s f) (GRef_ s g) a)
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
-> MutSumF s (GRef_ s f) (GRef_ s g) a
forall k s (f :: k -> *) (g :: k -> *) (a :: k).
MutVar s ((:+:) f g a) -> MutSumF s f g a
MutSumF (m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a))
-> (GRef_ s g a -> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)))
-> GRef_ s g a
-> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:+:) (GRef_ s f) (GRef_ s g) a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
forall (m :: * -> *) a.
PrimMonad m =>
a -> m (MutVar (PrimState m) a)
newMutVar ((:+:) (GRef_ s f) (GRef_ s g) a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)))
-> (GRef_ s g a -> (:+:) (GRef_ s f) (GRef_ s g) a)
-> GRef_ s g a
-> m (MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s g a -> (:+:) (GRef_ s f) (GRef_ s g) a
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
R1 (GRef_ s g a -> m (MutSumF s (GRef_ s f) (GRef_ s g) a))
-> m (GRef_ s g a) -> m (MutSumF s (GRef_ s f) (GRef_ s g) a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< g a -> m (GRef_ s g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gUnsafeThawRef_ g a
x
gUnsafeFreezeRef_ :: GRef_ s (f :+: g) a -> m ((:+:) f g a)
gUnsafeFreezeRef_ (MutSumF r) = MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
-> m ((:+:) (GRef_ s f) (GRef_ s g) a)
forall (m :: * -> *) a.
PrimMonad m =>
MutVar (PrimState m) a -> m a
readMutVar MutVar s ((:+:) (GRef_ s f) (GRef_ s g) a)
MutVar (PrimState m) ((:+:) (GRef_ s f) (GRef_ s g) a)
r m ((:+:) (GRef_ s f) (GRef_ s g) a)
-> ((:+:) (GRef_ s f) (GRef_ s g) a -> m ((:+:) f g a))
-> m ((:+:) f g a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
L1 v :: GRef_ s f a
v -> f a -> (:+:) f g a
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
L1 (f a -> (:+:) f g a) -> m (f a) -> m ((:+:) f g a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GRef_ s f a -> m (f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gUnsafeFreezeRef_ GRef_ s f a
v
R1 u :: GRef_ s g a
u -> g a -> (:+:) f g a
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
R1 (g a -> (:+:) f g a) -> m (g a) -> m ((:+:) f g a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GRef_ s g a -> m (g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gUnsafeFreezeRef_ GRef_ s g a
u
newtype GMutableRef s f a = GMutableRef { GMutableRef s f a -> GRef_ s f a
getGMutableRef :: GRef_ s f a }
deriving instance Eq (GRef_ s f a) => Eq (GMutableRef s f a)
deriving instance Ord (GRef_ s f a) => Ord (GMutableRef s f a)
thawGMutableRef :: (GMutable s f, PrimMonad m, PrimState m ~ s) => f a -> m (GMutableRef s f a)
thawGMutableRef :: f a -> m (GMutableRef s f a)
thawGMutableRef = (GRef_ s f a -> GMutableRef s f a)
-> m (GRef_ s f a) -> m (GMutableRef s f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap GRef_ s f a -> GMutableRef s f a
forall s (f :: * -> *) a. GRef_ s f a -> GMutableRef s f a
GMutableRef (m (GRef_ s f a) -> m (GMutableRef s f a))
-> (f a -> m (GRef_ s f a)) -> f a -> m (GMutableRef s f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> m (GRef_ s f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gThawRef_
freezeGMutableRef :: (GMutable s f, PrimMonad m, PrimState m ~ s) => GMutableRef s f a -> m (f a)
freezeGMutableRef :: GMutableRef s f a -> m (f a)
freezeGMutableRef = GRef_ s f a -> m (f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gFreezeRef_ (GRef_ s f a -> m (f a))
-> (GMutableRef s f a -> GRef_ s f a)
-> GMutableRef s f a
-> m (f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GMutableRef s f a -> GRef_ s f a
forall s (f :: * -> *) a. GMutableRef s f a -> GRef_ s f a
getGMutableRef
copyGMutableRef :: (GMutable s f, PrimMonad m, PrimState m ~ s) => GMutableRef s f a -> f a -> m ()
copyGMutableRef :: GMutableRef s f a -> f a -> m ()
copyGMutableRef (GMutableRef r :: GRef_ s f a
r) = GRef_ s f a -> f a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> f a -> m ()
gCopyRef_ GRef_ s f a
r
moveGMutableRef :: (GMutable s f, PrimMonad m, PrimState m ~ s) => GMutableRef s f a -> GMutableRef s f a -> m ()
moveGMutableRef :: GMutableRef s f a -> GMutableRef s f a -> m ()
moveGMutableRef (GMutableRef r :: GRef_ s f a
r) (GMutableRef s :: GRef_ s f a
s) = GRef_ s f a -> GRef_ s f a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> GRef_ s f a -> m ()
gMoveRef_ GRef_ s f a
r GRef_ s f a
s
cloneGMutableRef :: (GMutable s f, PrimMonad m, PrimState m ~ s) => GMutableRef s f a -> m (GMutableRef s f a)
cloneGMutableRef :: GMutableRef s f a -> m (GMutableRef s f a)
cloneGMutableRef (GMutableRef r :: GRef_ s f a
r) = GRef_ s f a -> GMutableRef s f a
forall s (f :: * -> *) a. GRef_ s f a -> GMutableRef s f a
GMutableRef (GRef_ s f a -> GMutableRef s f a)
-> m (GRef_ s f a) -> m (GMutableRef s f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GRef_ s f a -> m (GRef_ s f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (GRef_ s f a)
gCloneRef_ GRef_ s f a
r
unsafeThawGMutableRef :: (GMutable s f, PrimMonad m, PrimState m ~ s) => f a -> m (GMutableRef s f a)
unsafeThawGMutableRef :: f a -> m (GMutableRef s f a)
unsafeThawGMutableRef = (GRef_ s f a -> GMutableRef s f a)
-> m (GRef_ s f a) -> m (GMutableRef s f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap GRef_ s f a -> GMutableRef s f a
forall s (f :: * -> *) a. GRef_ s f a -> GMutableRef s f a
GMutableRef (m (GRef_ s f a) -> m (GMutableRef s f a))
-> (f a -> m (GRef_ s f a)) -> f a -> m (GMutableRef s f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> m (GRef_ s f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gUnsafeThawRef_
unsafeFreezeGMutableRef :: (GMutable s f, PrimMonad m, PrimState m ~ s) => GMutableRef s f a -> m (f a)
unsafeFreezeGMutableRef :: GMutableRef s f a -> m (f a)
unsafeFreezeGMutableRef = GRef_ s f a -> m (f a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gUnsafeFreezeRef_ (GRef_ s f a -> m (f a))
-> (GMutableRef s f a -> GRef_ s f a)
-> GMutableRef s f a
-> m (f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GMutableRef s f a -> GRef_ s f a
forall s (f :: * -> *) a. GMutableRef s f a -> GRef_ s f a
getGMutableRef
instance Mutable s c => Mutable s (K1 i c (a :: Type)) where
type Ref s (K1 i c a) = GMutableRef s (K1 i c) a
thawRef :: K1 i c a -> m (Ref s (K1 i c a))
thawRef = K1 i c a -> m (Ref s (K1 i c a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GMutableRef s f a)
thawGMutableRef
freezeRef :: Ref s (K1 i c a) -> m (K1 i c a)
freezeRef = Ref s (K1 i c a) -> m (K1 i c a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (f a)
freezeGMutableRef
copyRef :: Ref s (K1 i c a) -> K1 i c a -> m ()
copyRef = Ref s (K1 i c a) -> K1 i c a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> f a -> m ()
copyGMutableRef
moveRef :: Ref s (K1 i c a) -> Ref s (K1 i c a) -> m ()
moveRef = Ref s (K1 i c a) -> Ref s (K1 i c a) -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> GMutableRef s f a -> m ()
moveGMutableRef
cloneRef :: Ref s (K1 i c a) -> m (Ref s (K1 i c a))
cloneRef = Ref s (K1 i c a) -> m (Ref s (K1 i c a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (GMutableRef s f a)
cloneGMutableRef
unsafeThawRef :: K1 i c a -> m (Ref s (K1 i c a))
unsafeThawRef = K1 i c a -> m (Ref s (K1 i c a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GMutableRef s f a)
unsafeThawGMutableRef
unsafeFreezeRef :: Ref s (K1 i c a) -> m (K1 i c a)
unsafeFreezeRef = Ref s (K1 i c a) -> m (K1 i c a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (f a)
unsafeFreezeGMutableRef
instance Mutable s (U1 (a :: Type)) where
type Ref s (U1 a) = GMutableRef s U1 a
thawRef :: U1 a -> m (Ref s (U1 a))
thawRef = U1 a -> m (Ref s (U1 a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GMutableRef s f a)
thawGMutableRef
freezeRef :: Ref s (U1 a) -> m (U1 a)
freezeRef = Ref s (U1 a) -> m (U1 a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (f a)
freezeGMutableRef
copyRef :: Ref s (U1 a) -> U1 a -> m ()
copyRef = Ref s (U1 a) -> U1 a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> f a -> m ()
copyGMutableRef
moveRef :: Ref s (U1 a) -> Ref s (U1 a) -> m ()
moveRef = Ref s (U1 a) -> Ref s (U1 a) -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> GMutableRef s f a -> m ()
moveGMutableRef
cloneRef :: Ref s (U1 a) -> m (Ref s (U1 a))
cloneRef = Ref s (U1 a) -> m (Ref s (U1 a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (GMutableRef s f a)
cloneGMutableRef
unsafeThawRef :: U1 a -> m (Ref s (U1 a))
unsafeThawRef = U1 a -> m (Ref s (U1 a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GMutableRef s f a)
unsafeThawGMutableRef
unsafeFreezeRef :: Ref s (U1 a) -> m (U1 a)
unsafeFreezeRef = Ref s (U1 a) -> m (U1 a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (f a)
unsafeFreezeGMutableRef
instance Mutable s (V1 (a :: Type)) where
type Ref s (V1 a) = GMutableRef s V1 a
thawRef :: V1 a -> m (Ref s (V1 a))
thawRef = V1 a -> m (Ref s (V1 a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GMutableRef s f a)
thawGMutableRef
freezeRef :: Ref s (V1 a) -> m (V1 a)
freezeRef = Ref s (V1 a) -> m (V1 a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (f a)
freezeGMutableRef
copyRef :: Ref s (V1 a) -> V1 a -> m ()
copyRef = Ref s (V1 a) -> V1 a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> f a -> m ()
copyGMutableRef
moveRef :: Ref s (V1 a) -> Ref s (V1 a) -> m ()
moveRef = Ref s (V1 a) -> Ref s (V1 a) -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> GMutableRef s f a -> m ()
moveGMutableRef
cloneRef :: Ref s (V1 a) -> m (Ref s (V1 a))
cloneRef = Ref s (V1 a) -> m (Ref s (V1 a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (GMutableRef s f a)
cloneGMutableRef
unsafeThawRef :: V1 a -> m (Ref s (V1 a))
unsafeThawRef = V1 a -> m (Ref s (V1 a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GMutableRef s f a)
unsafeThawGMutableRef
unsafeFreezeRef :: Ref s (V1 a) -> m (V1 a)
unsafeFreezeRef = Ref s (V1 a) -> m (V1 a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (f a)
unsafeFreezeGMutableRef
instance (GMutable s f, GMutable s g) => Mutable s ((f :*: g) a) where
type Ref s ((f :*: g) a) = GMutableRef s (f :*: g) a
thawRef :: (:*:) f g a -> m (Ref s ((:*:) f g a))
thawRef = (:*:) f g a -> m (Ref s ((:*:) f g a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GMutableRef s f a)
thawGMutableRef
freezeRef :: Ref s ((:*:) f g a) -> m ((:*:) f g a)
freezeRef = Ref s ((:*:) f g a) -> m ((:*:) f g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (f a)
freezeGMutableRef
copyRef :: Ref s ((:*:) f g a) -> (:*:) f g a -> m ()
copyRef = Ref s ((:*:) f g a) -> (:*:) f g a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> f a -> m ()
copyGMutableRef
moveRef :: Ref s ((:*:) f g a) -> Ref s ((:*:) f g a) -> m ()
moveRef = Ref s ((:*:) f g a) -> Ref s ((:*:) f g a) -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> GMutableRef s f a -> m ()
moveGMutableRef
cloneRef :: Ref s ((:*:) f g a) -> m (Ref s ((:*:) f g a))
cloneRef = Ref s ((:*:) f g a) -> m (Ref s ((:*:) f g a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (GMutableRef s f a)
cloneGMutableRef
unsafeThawRef :: (:*:) f g a -> m (Ref s ((:*:) f g a))
unsafeThawRef = (:*:) f g a -> m (Ref s ((:*:) f g a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GMutableRef s f a)
unsafeThawGMutableRef
unsafeFreezeRef :: Ref s ((:*:) f g a) -> m ((:*:) f g a)
unsafeFreezeRef = Ref s ((:*:) f g a) -> m ((:*:) f g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (f a)
unsafeFreezeGMutableRef
instance (GMutable s f, GMutable s g) => Mutable s ((f :+: g) a) where
type Ref s ((f :+: g) a) = GMutableRef s (f :+: g) a
thawRef :: (:+:) f g a -> m (Ref s ((:+:) f g a))
thawRef = (:+:) f g a -> m (Ref s ((:+:) f g a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GMutableRef s f a)
thawGMutableRef
freezeRef :: Ref s ((:+:) f g a) -> m ((:+:) f g a)
freezeRef = Ref s ((:+:) f g a) -> m ((:+:) f g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (f a)
freezeGMutableRef
copyRef :: Ref s ((:+:) f g a) -> (:+:) f g a -> m ()
copyRef = Ref s ((:+:) f g a) -> (:+:) f g a -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> f a -> m ()
copyGMutableRef
moveRef :: Ref s ((:+:) f g a) -> Ref s ((:+:) f g a) -> m ()
moveRef = Ref s ((:+:) f g a) -> Ref s ((:+:) f g a) -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> GMutableRef s f a -> m ()
moveGMutableRef
cloneRef :: Ref s ((:+:) f g a) -> m (Ref s ((:+:) f g a))
cloneRef = Ref s ((:+:) f g a) -> m (Ref s ((:+:) f g a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (GMutableRef s f a)
cloneGMutableRef
unsafeThawRef :: (:+:) f g a -> m (Ref s ((:+:) f g a))
unsafeThawRef = (:+:) f g a -> m (Ref s ((:+:) f g a))
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GMutableRef s f a)
unsafeThawGMutableRef
unsafeFreezeRef :: Ref s ((:+:) f g a) -> m ((:+:) f g a)
unsafeFreezeRef = Ref s ((:+:) f g a) -> m ((:+:) f g a)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GMutableRef s f a -> m (f a)
unsafeFreezeGMutableRef
newtype GRef s a = GRef { GRef s a -> GRef_ s (Rep a) ()
unGRef :: GRef_ s (Rep a) () }
deriving instance Eq (GRef_ s (Rep a) ()) => Eq (GRef s a)
deriving instance Ord (GRef_ s (Rep a) ()) => Ord (GRef s a)
gThawRef
:: (Generic a, GMutable s (Rep a), PrimMonad m, PrimState m ~ s)
=> a
-> m (GRef s a)
gThawRef :: a -> m (GRef s a)
gThawRef = (GRef_ s (Rep a) () -> GRef s a)
-> m (GRef_ s (Rep a) ()) -> m (GRef s a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap GRef_ s (Rep a) () -> GRef s a
forall s a. GRef_ s (Rep a) () -> GRef s a
GRef (m (GRef_ s (Rep a) ()) -> m (GRef s a))
-> (a -> m (GRef_ s (Rep a) ())) -> a -> m (GRef s a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rep a () -> m (GRef_ s (Rep a) ())
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gThawRef_ (Rep a () -> m (GRef_ s (Rep a) ()))
-> (a -> Rep a ()) -> a -> m (GRef_ s (Rep a) ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Rep a ()
forall a x. Generic a => a -> Rep a x
from
gFreezeRef
:: (Generic a, GMutable s (Rep a), PrimMonad m, PrimState m ~ s)
=> GRef s a
-> m a
gFreezeRef :: GRef s a -> m a
gFreezeRef = (Rep a () -> a) -> m (Rep a ()) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Rep a () -> a
forall a x. Generic a => Rep a x -> a
to (m (Rep a ()) -> m a)
-> (GRef s a -> m (Rep a ())) -> GRef s a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s (Rep a) () -> m (Rep a ())
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gFreezeRef_ (GRef_ s (Rep a) () -> m (Rep a ()))
-> (GRef s a -> GRef_ s (Rep a) ()) -> GRef s a -> m (Rep a ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef s a -> GRef_ s (Rep a) ()
forall s a. GRef s a -> GRef_ s (Rep a) ()
unGRef
gCopyRef
:: (Generic a, GMutable s (Rep a), PrimMonad m, PrimState m ~ s)
=> GRef s a
-> a
-> m ()
gCopyRef :: GRef s a -> a -> m ()
gCopyRef (GRef v :: GRef_ s (Rep a) ()
v) x :: a
x = GRef_ s (Rep a) () -> Rep a () -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> f a -> m ()
gCopyRef_ GRef_ s (Rep a) ()
v (a -> Rep a ()
forall a x. Generic a => a -> Rep a x
from a
x)
gMoveRef
:: (GMutable s (Rep a), PrimMonad m, PrimState m ~ s)
=> GRef s a
-> GRef s a
-> m ()
gMoveRef :: GRef s a -> GRef s a -> m ()
gMoveRef (GRef v :: GRef_ s (Rep a) ()
v) (GRef u :: GRef_ s (Rep a) ()
u) = GRef_ s (Rep a) () -> GRef_ s (Rep a) () -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> GRef_ s f a -> m ()
gMoveRef_ GRef_ s (Rep a) ()
v GRef_ s (Rep a) ()
u
gCloneRef
:: (GMutable s (Rep a), PrimMonad m, PrimState m ~ s)
=> GRef s a
-> m (GRef s a)
gCloneRef :: GRef s a -> m (GRef s a)
gCloneRef (GRef v :: GRef_ s (Rep a) ()
v) = GRef_ s (Rep a) () -> GRef s a
forall s a. GRef_ s (Rep a) () -> GRef s a
GRef (GRef_ s (Rep a) () -> GRef s a)
-> m (GRef_ s (Rep a) ()) -> m (GRef s a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GRef_ s (Rep a) () -> m (GRef_ s (Rep a) ())
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (GRef_ s f a)
gCloneRef_ GRef_ s (Rep a) ()
v
gUnsafeThawRef
:: (Generic a, GMutable s (Rep a), PrimMonad m, PrimState m ~ s)
=> a
-> m (GRef s a)
gUnsafeThawRef :: a -> m (GRef s a)
gUnsafeThawRef = (GRef_ s (Rep a) () -> GRef s a)
-> m (GRef_ s (Rep a) ()) -> m (GRef s a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap GRef_ s (Rep a) () -> GRef s a
forall s a. GRef_ s (Rep a) () -> GRef s a
GRef (m (GRef_ s (Rep a) ()) -> m (GRef s a))
-> (a -> m (GRef_ s (Rep a) ())) -> a -> m (GRef s a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rep a () -> m (GRef_ s (Rep a) ())
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gUnsafeThawRef_ (Rep a () -> m (GRef_ s (Rep a) ()))
-> (a -> Rep a ()) -> a -> m (GRef_ s (Rep a) ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Rep a ()
forall a x. Generic a => a -> Rep a x
from
gUnsafeFreezeRef
:: (Generic a, GMutable s (Rep a), PrimMonad m, PrimState m ~ s)
=> GRef s a
-> m a
gUnsafeFreezeRef :: GRef s a -> m a
gUnsafeFreezeRef = (Rep a () -> a) -> m (Rep a ()) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Rep a () -> a
forall a x. Generic a => Rep a x -> a
to (m (Rep a ()) -> m a)
-> (GRef s a -> m (Rep a ())) -> GRef s a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s (Rep a) () -> m (Rep a ())
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gUnsafeFreezeRef_ (GRef_ s (Rep a) () -> m (Rep a ()))
-> (GRef s a -> GRef_ s (Rep a) ()) -> GRef s a -> m (Rep a ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef s a -> GRef_ s (Rep a) ()
forall s a. GRef s a -> GRef_ s (Rep a) ()
unGRef
thawHKD
:: forall z m s.
( Generic (z Identity)
, Generic (z (RefFor s))
, GMutable s (Rep (z Identity))
, GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s))
, PrimMonad m
, PrimState m ~ s
)
=> z Identity
-> m (z (RefFor s))
thawHKD :: z Identity -> m (z (RefFor s))
thawHKD = (Rep (z (RefFor s)) Any -> z (RefFor s))
-> m (Rep (z (RefFor s)) Any) -> m (z (RefFor s))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Rep (z (RefFor s)) Any -> z (RefFor s)
forall a x. Generic a => Rep a x -> a
to (m (Rep (z (RefFor s)) Any) -> m (z (RefFor s)))
-> (z Identity -> m (Rep (z (RefFor s)) Any))
-> z Identity
-> m (z (RefFor s))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rep (z Identity) Any -> m (Rep (z (RefFor s)) Any)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gThawRef_ (Rep (z Identity) Any -> m (Rep (z (RefFor s)) Any))
-> (z Identity -> Rep (z Identity) Any)
-> z Identity
-> m (Rep (z (RefFor s)) Any)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. z Identity -> Rep (z Identity) Any
forall a x. Generic a => a -> Rep a x
from
freezeHKD
:: forall z m s.
( Generic (z Identity)
, Generic (z (RefFor s))
, GMutable s (Rep (z Identity))
, GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s))
, PrimMonad m
, PrimState m ~ s
)
=> z (RefFor s)
-> m (z Identity)
freezeHKD :: z (RefFor s) -> m (z Identity)
freezeHKD = (Rep (z Identity) Any -> z Identity)
-> m (Rep (z Identity) Any) -> m (z Identity)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Rep (z Identity) Any -> z Identity
forall a x. Generic a => Rep a x -> a
to (m (Rep (z Identity) Any) -> m (z Identity))
-> (z (RefFor s) -> m (Rep (z Identity) Any))
-> z (RefFor s)
-> m (z Identity)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rep (z (RefFor s)) Any -> m (Rep (z Identity) Any)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gFreezeRef_ (Rep (z (RefFor s)) Any -> m (Rep (z Identity) Any))
-> (z (RefFor s) -> Rep (z (RefFor s)) Any)
-> z (RefFor s)
-> m (Rep (z Identity) Any)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. z (RefFor s) -> Rep (z (RefFor s)) Any
forall a x. Generic a => a -> Rep a x
from
copyHKD
:: forall z m s.
( Generic (z Identity)
, Generic (z (RefFor s))
, GMutable s (Rep (z Identity))
, GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s))
, PrimMonad m
, PrimState m ~ s
)
=> z (RefFor s)
-> z Identity
-> m ()
copyHKD :: z (RefFor s) -> z Identity -> m ()
copyHKD r :: z (RefFor s)
r x :: z Identity
x = GRef_ s (Rep (z Identity)) Any -> Rep (z Identity) Any -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> f a -> m ()
gCopyRef_ (z (RefFor s) -> Rep (z (RefFor s)) Any
forall a x. Generic a => a -> Rep a x
from z (RefFor s)
r) (z Identity -> Rep (z Identity) Any
forall a x. Generic a => a -> Rep a x
from z Identity
x)
moveHKD
:: forall z m s.
( Generic (z (RefFor s))
, GMutable s (Rep (z Identity))
, GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s))
, PrimMonad m
, PrimState m ~ s
)
=> z (RefFor s)
-> z (RefFor s)
-> m ()
moveHKD :: z (RefFor s) -> z (RefFor s) -> m ()
moveHKD r :: z (RefFor s)
r x :: z (RefFor s)
x = GRef_ s (Rep (z Identity)) Any
-> GRef_ s (Rep (z Identity)) Any -> m ()
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> GRef_ s f a -> m ()
gMoveRef_ (z (RefFor s) -> Rep (z (RefFor s)) Any
forall a x. Generic a => a -> Rep a x
from z (RefFor s)
r) (z (RefFor s) -> Rep (z (RefFor s)) Any
forall a x. Generic a => a -> Rep a x
from z (RefFor s)
x)
cloneHKD
:: forall z m s.
( Generic (z (RefFor s))
, GMutable s (Rep (z Identity))
, GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s))
, PrimMonad m
, PrimState m ~ s
)
=> z (RefFor s)
-> m (z (RefFor s))
cloneHKD :: z (RefFor s) -> m (z (RefFor s))
cloneHKD = (Rep (z (RefFor s)) Any -> z (RefFor s))
-> m (Rep (z (RefFor s)) Any) -> m (z (RefFor s))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Rep (z (RefFor s)) Any -> z (RefFor s)
forall a x. Generic a => Rep a x -> a
to (m (Rep (z (RefFor s)) Any) -> m (z (RefFor s)))
-> (z (RefFor s) -> m (Rep (z (RefFor s)) Any))
-> z (RefFor s)
-> m (z (RefFor s))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRef_ s (Rep (z Identity)) Any -> m (Rep (z (RefFor s)) Any)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (GRef_ s f a)
gCloneRef_ (GRef_ s (Rep (z Identity)) Any -> m (Rep (z (RefFor s)) Any))
-> (z (RefFor s) -> GRef_ s (Rep (z Identity)) Any)
-> z (RefFor s)
-> m (Rep (z (RefFor s)) Any)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. z (RefFor s) -> GRef_ s (Rep (z Identity)) Any
forall a x. Generic a => a -> Rep a x
from
unsafeThawHKD
:: forall z m s.
( Generic (z Identity)
, Generic (z (RefFor s))
, GMutable s (Rep (z Identity))
, GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s))
, PrimMonad m
, PrimState m ~ s
)
=> z Identity
-> m (z (RefFor s))
unsafeThawHKD :: z Identity -> m (z (RefFor s))
unsafeThawHKD = (Rep (z (RefFor s)) Any -> z (RefFor s))
-> m (Rep (z (RefFor s)) Any) -> m (z (RefFor s))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Rep (z (RefFor s)) Any -> z (RefFor s)
forall a x. Generic a => Rep a x -> a
to (m (Rep (z (RefFor s)) Any) -> m (z (RefFor s)))
-> (z Identity -> m (Rep (z (RefFor s)) Any))
-> z Identity
-> m (z (RefFor s))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rep (z Identity) Any -> m (Rep (z (RefFor s)) Any)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
f a -> m (GRef_ s f a)
gUnsafeThawRef_ (Rep (z Identity) Any -> m (Rep (z (RefFor s)) Any))
-> (z Identity -> Rep (z Identity) Any)
-> z Identity
-> m (Rep (z (RefFor s)) Any)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. z Identity -> Rep (z Identity) Any
forall a x. Generic a => a -> Rep a x
from
unsafeFreezeHKD
:: forall z m s.
( Generic (z Identity)
, Generic (z (RefFor s))
, GMutable s (Rep (z Identity))
, GRef_ s (Rep (z Identity)) ~ Rep (z (RefFor s))
, PrimMonad m
, PrimState m ~ s
)
=> z (RefFor s)
-> m (z Identity)
unsafeFreezeHKD :: z (RefFor s) -> m (z Identity)
unsafeFreezeHKD = (Rep (z Identity) Any -> z Identity)
-> m (Rep (z Identity) Any) -> m (z Identity)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Rep (z Identity) Any -> z Identity
forall a x. Generic a => Rep a x -> a
to (m (Rep (z Identity) Any) -> m (z Identity))
-> (z (RefFor s) -> m (Rep (z Identity) Any))
-> z (RefFor s)
-> m (z Identity)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rep (z (RefFor s)) Any -> m (Rep (z Identity) Any)
forall s (f :: * -> *) (m :: * -> *) a.
(GMutable s f, PrimMonad m, PrimState m ~ s) =>
GRef_ s f a -> m (f a)
gUnsafeFreezeRef_ (Rep (z (RefFor s)) Any -> m (Rep (z Identity) Any))
-> (z (RefFor s) -> Rep (z (RefFor s)) Any)
-> z (RefFor s)
-> m (Rep (z Identity) Any)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. z (RefFor s) -> Rep (z (RefFor s)) Any
forall a x. Generic a => a -> Rep a x
from
type family MapRef s as where
MapRef s '[] = '[]
MapRef s (a ': as) = Ref s a ': MapRef s as
class ListRefTuple (s :: Type) (b :: Type) (as :: [Type]) | as s -> b where
tupledRef :: GL.Iso' (HList (MapRef s as)) b
tupledRef = (HList (MapRef s as) -> b)
-> (b -> HList (MapRef s as))
-> Iso (HList (MapRef s as)) (HList (MapRef s as)) b b
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
GL.iso (ListRefTuple s b as => HList (MapRef s as) -> b
forall s b (as :: [*]).
ListRefTuple s b as =>
HList (MapRef s as) -> b
listRefToTuple @s @b @as) (ListRefTuple s b as => b -> HList (MapRef s as)
forall s b (as :: [*]).
ListRefTuple s b as =>
b -> HList (MapRef s as)
tupleToListRef @s @b @as)
{-# INLINE tupledRef #-}
tupleToListRef :: b -> HList (MapRef s as)
listRefToTuple :: HList (MapRef s as) -> b