Skip to content

Commit

Permalink
quasar: Rename observable cache operation to share
Browse files Browse the repository at this point in the history
  • Loading branch information
queezle42 committed Jun 13, 2024
1 parent 729aadd commit 737afcd
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 157 deletions.
2 changes: 1 addition & 1 deletion quasar/quasar.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ library
Quasar.MonadQuasar.Misc
Quasar.Observable.AccumulatingObserver
Quasar.Observable.Async
Quasar.Observable.Cache
Quasar.Observable.Core
Quasar.Observable.Lift
Quasar.Observable.List
Quasar.Observable.Loading
Quasar.Observable.Map
Quasar.Observable.ObservableVar
Quasar.Observable.Set
Quasar.Observable.Share
Quasar.Observable.Subject
Quasar.Observable.Traversable
Quasar.Pool
Expand Down
138 changes: 0 additions & 138 deletions quasar/src/Quasar/Observable/Cache.hs

This file was deleted.

10 changes: 5 additions & 5 deletions quasar/src/Quasar/Observable/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ class IsObservableCore canLoad exceptions c v a | a -> canLoad, a -> exceptions,

pure ((disposer, initial), createObserverState initial)

isCachedObservable# :: a -> Bool
isCachedObservable# _ = False
isSharedObservable# :: a -> Bool
isSharedObservable# _ = False

mapObservable# :: ObservableFunctor c => (v -> vb) -> a -> MappedObservable canLoad exceptions c vb
mapObservable# f x = MappedObservable f x
Expand Down Expand Up @@ -220,7 +220,7 @@ instance IsObservableCore canLoad exceptions c v (ObservableT canLoad exceptions
readObservable# (ObservableT x) = readObservable# x
attachObserver# (ObservableT x) = attachObserver# x
attachEvaluatedObserver# (ObservableT x) = attachEvaluatedObserver# x
isCachedObservable# (ObservableT x) = isCachedObservable# x
isSharedObservable# (ObservableT x) = isSharedObservable# x
mapObservable# f (ObservableT x) = mapObservable# f x
count# (ObservableT x) = count# x
isEmpty# (ObservableT x) = isEmpty# x
Expand Down Expand Up @@ -686,7 +686,7 @@ instance Semigroup (c v) => Semigroup (ObservableState canLoad c v) where
instance IsObservableCore canLoad exceptions c v (ObservableState canLoad (ObservableResult exceptions c) v) where
readObservable# = pure
attachObserver# x _callback = pure (mempty, x)
isCachedObservable# _ = True
isSharedObservable# _ = True
count# x = constObservable (mapObservableStateResult (Identity . containerCount#) x)
isEmpty# x = constObservable (mapObservableStateResult (Identity . containerIsEmpty#) x)

Expand Down Expand Up @@ -1632,7 +1632,7 @@ instance IsObservableCore canLoad exceptions Identity v (Observable canLoad exce
readObservable# (Observable x) = readObservable# x
attachObserver# (Observable x) = attachObserver# x
attachEvaluatedObserver# (Observable x) = attachEvaluatedObserver# x
isCachedObservable# (Observable x) = isCachedObservable# x
isSharedObservable# (Observable x) = isSharedObservable# x
mapObservable# f (Observable x) = mapObservable# f x
count# (Observable x) = count# x
isEmpty# (Observable x) = isEmpty# x
Expand Down
12 changes: 6 additions & 6 deletions quasar/src/Quasar/Observable/List.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Quasar.Observable.List (
validatedListDeltaLength,
ListDeltaOperation(..),
Length(..),
cache,
share,

-- * Reexports
FingerTree,
Expand Down Expand Up @@ -59,8 +59,8 @@ import Data.Sequence (Seq(Empty))
import Data.Sequence qualified as Seq
import Data.Traversable qualified as Traversable
import Quasar.Disposer (TDisposer)
import Quasar.Observable.Cache
import Quasar.Observable.Core
import Quasar.Observable.Share
import Quasar.Observable.Subject
import Quasar.Observable.Traversable
import Quasar.Prelude hiding (traverse)
Expand Down Expand Up @@ -342,7 +342,7 @@ instance IsObservableCore canLoad exceptions Seq v (ObservableList canLoad excep
readObservable# (ObservableList x) = readObservable# x
attachObserver# (ObservableList x) = attachObserver# x
attachEvaluatedObserver# (ObservableList x) = attachEvaluatedObserver# x
isCachedObservable# (ObservableList x) = isCachedObservable# x
isSharedObservable# (ObservableList x) = isSharedObservable# x

instance IsObservableList canLoad exceptions v (ObservableList canLoad exceptions v) where
--member# (ObservableList (ObservableT x)) = member# x
Expand Down Expand Up @@ -392,13 +392,13 @@ isEmpty :: ObservableList l e v -> Observable l e Bool
isEmpty fx = isEmpty# fx


instance IsObservableList canLoad exceptions v (CachedObservable canLoad exceptions Seq v) where
instance IsObservableList canLoad exceptions v (SharedObservable canLoad exceptions Seq v) where

cache ::
share ::
MonadSTMc NoRetry '[] m =>
ObservableList canLoad exceptions v ->
m (ObservableList canLoad exceptions v)
cache (ObservableList f) = ObservableList <$> cacheObservableT f
share (ObservableList f) = ObservableList <$> shareObservableT f


constObservableList :: ObservableState canLoad (ObservableResult exceptions Seq) v -> ObservableList canLoad exceptions v
Expand Down
12 changes: 6 additions & 6 deletions quasar/src/Quasar/Observable/Map.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Quasar.Observable.Map (
liftObservableMap,
IsObservableMap(..),
query,
cache,
share,

-- ** Delta types
MapDelta(..),
Expand Down Expand Up @@ -85,11 +85,11 @@ import Data.Sequence qualified as Seq
import Data.Traversable qualified as Traversable
import GHC.Records (HasField (..))
import Quasar.Disposer
import Quasar.Observable.Cache
import Quasar.Observable.Core
import Quasar.Observable.Lift
import Quasar.Observable.List (ObservableList(..), IsObservableList, ListOperation(..))
import Quasar.Observable.List qualified as ObservableList
import Quasar.Observable.Share
import Quasar.Observable.Subject
import Quasar.Observable.Traversable
import Quasar.Prelude hiding (filter, lookup, traverse)
Expand Down Expand Up @@ -206,7 +206,7 @@ instance IsObservableCore canLoad exceptions (Map k) v (ObservableMap canLoad ex
readObservable# (ObservableMap (ObservableT x)) = readObservable# x
attachObserver# (ObservableMap x) = attachObserver# x
attachEvaluatedObserver# (ObservableMap x) = attachEvaluatedObserver# x
isCachedObservable# (ObservableMap (ObservableT x)) = isCachedObservable# x
isSharedObservable# (ObservableMap (ObservableT x)) = isSharedObservable# x

instance IsObservableMap canLoad exceptions k v (ObservableMap canLoad exceptions k v) where
lookupKey# (ObservableMap x) = lookupKey# x
Expand Down Expand Up @@ -234,14 +234,14 @@ query x = query# (toObservableMap x)



instance Ord k => IsObservableMap canLoad exceptions k v (CachedObservable canLoad exceptions (Map k) v) where
instance Ord k => IsObservableMap canLoad exceptions k v (SharedObservable canLoad exceptions (Map k) v) where
-- TODO

cache ::
share ::
(Ord k, MonadSTMc NoRetry '[] m) =>
ObservableMap canLoad exceptions k v ->
m (ObservableMap canLoad exceptions k v)
cache (ObservableMap f) = ObservableMap <$> cacheObservableT f
share (ObservableMap f) = ObservableMap <$> shareObservableT f



Expand Down
2 changes: 1 addition & 1 deletion quasar/src/Quasar/Observable/Set.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ instance Ord v => IsObservableCore canLoad exceptions Set v (ObservableSet canLo
readObservable# (ObservableSet x) = readObservable# x
attachObserver# (ObservableSet x) = attachObserver# x
attachEvaluatedObserver# (ObservableSet x) = attachEvaluatedObserver# x
isCachedObservable# (ObservableSet x) = isCachedObservable# x
isSharedObservable# (ObservableSet x) = isSharedObservable# x

instance Ord v => IsObservableSet canLoad exceptions v (ObservableSet canLoad exceptions v) where
--member# (ObservableSet x) = member# x
Expand Down
Loading

0 comments on commit 737afcd

Please sign in to comment.