Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Vessel (k :: ((* -> *) -> *) -> *) (g :: * -> *) = Vessel {
- unVessel :: MonoidalDMap k (FlipAp g)
- class View (v :: (* -> *) -> *) where
- condenseV :: (Foldable t, Filterable t, Functor t) => t (v g) -> v (Compose t g)
- disperseV :: Align t => v (Compose t g) -> t (v g)
- cropV :: (forall a. s a -> i a -> r a) -> v s -> v i -> Maybe (v r)
- nullV :: v i -> Bool
- mapV :: (forall a. f a -> g a) -> v f -> v g
- traverseV :: Applicative m => (forall a. f a -> m (g a)) -> v f -> m (v g)
- mapMaybeV :: (forall a. f a -> Maybe (g a)) -> v f -> Maybe (v g)
- alignWithMaybeV :: (forall a. These (f a) (g a) -> Maybe (h a)) -> v f -> v g -> Maybe (v h)
- alignWithV :: (forall a. These (f a) (g a) -> h a) -> v f -> v g -> v h
- class View v => EmptyView v where
- emptyV :: v f
- class Selectable v k where
- newtype FlipAp (g :: k) (v :: k -> *) = FlipAp {
- unFlipAp :: v g
- newtype IdentityV (a :: *) (g :: * -> *) = IdentityV {
- unIdentityV :: g a
- newtype SingleV (a :: *) (g :: * -> *) = SingleV {}
- newtype MapV k v g = MapV {
- unMapV :: MonoidalMap k (g v)
- newtype DMapV (k :: * -> *) (v :: * -> *) g = DMapV {
- unDMapV :: MonoidalDMap k (Compose g v)
- singletonV :: View v => k v -> v g -> Vessel k g
- lookupV :: GCompare k => k v -> Vessel k g -> Maybe (v g)
- buildV :: (GCompare k, Has View k, Applicative m) => Vessel k g -> (forall v. k v -> v g -> m (v h)) -> m (Vessel k h)
- subtractV :: View v => v f -> v g -> Maybe (v f)
- mapMaybeWithKeyV :: (GCompare k, Has View k) => (forall v. View v => k v -> v g -> Maybe (v g')) -> Vessel k g -> Vessel k g'
- traverseWithKeyV :: (GCompare k, Has View k, Applicative m) => (forall v. View v => k v -> v g -> m (v h)) -> Vessel k g -> m (Vessel k h)
- traverseWithKeyV_ :: (GCompare k, Has View k, Applicative m) => (forall v. View v => k v -> v g -> m ()) -> Vessel k g -> m ()
- intersectionWithKeyV :: (GCompare k, Has View k) => (forall v. View v => k v -> v g -> v g' -> v h) -> Vessel k g -> Vessel k g' -> Vessel k h
- mapDecomposedV :: (Functor m, View v) => (v Proxy -> m (v Identity)) -> v (Compose (MonoidalMap c) g) -> m (Maybe (v (Compose (MonoidalMap c) Identity)))
- alignWithMV :: forall m v f g h. (View v, Applicative m) => (forall a. These (f a) (g a) -> m (h a)) -> v f -> v g -> m (Maybe (v h))
- collapseNullV :: View v => v f -> Maybe (v f)
- data VSum (k :: ((* -> *) -> *) -> *) (g :: * -> *) = (k v) :~> (v g)
- toListV :: Vessel k g -> [VSum k g]
- fromListV :: (GCompare k, Has View k) => [VSum k g] -> Vessel k g
- module Data.Proxy
- module Data.Functor.Identity
- module Data.Functor.Const
- module Data.Functor.Compose
- transposeView :: (View v, Foldable t, Filterable t, Functor t, Align t, QueryResult (t (v g)) ~ t (v g'), QueryResult (v (Compose t g)) ~ v (Compose t g'), Monoid (v g), Monoid (v (Compose t g))) => QueryMorphism (t (v g)) (v (Compose t g))
- class Disperse row where
- newtype SubVessel (k :: *) (v :: (* -> *) -> *) (f :: * -> *) = SubVessel {
- unSubVessel :: Vessel (SubVesselKey k v) f
- traverseSubVessel :: (Ord k, View v, Applicative m) => (k -> v g -> m (v h)) -> SubVessel k v g -> m (SubVessel k v h)
- singletonSubVessel :: forall k f v. View v => k -> v f -> SubVessel k v f
- lookupSubVessel :: Ord k => k -> SubVessel k v f -> Maybe (v f)
Documentation
newtype Vessel (k :: ((* -> *) -> *) -> *) (g :: * -> *) Source #
This type is a container for storing an arbitrary collection of functor-parametric container types of the sort discussed above, keyed by a GADT whose index will specify which sort of container goes in each position.
Ordinary types with values have kind * Functors have kind * -> * Containers taking a functor as a parameter then have kind (* -> *) -> * The keys of a vessel are indexed by a functor-parametric container type, so they have kind ((* -> *) -> *) -> * Vessel itself, for any such key type, produces a functor-parametric container, so it has kind (((* -> *) -> *) -> *) -> (* -> *) -> * Law: None of the items in the Vessel's MonoidalDMap are nullV
Vessel | |
|
Instances
class View (v :: (* -> *) -> *) where Source #
Our containers are parameterised by a choice of functor to apply at the leaves of their structure. By applying them to Identity, we obtain ordinary containers for data, called "views". By applying them to Proxy, we obtain what are effectively blank forms to be filled in, called "queries" or "view selectors". By using a functor such as Map k, information about many queries or their results may be aggregated together into a single container.
This class codifies the operations we need to be able to perform on these container types in order to transpose various Map-like structures into and out of them.
This is done for the purposes of, on the one hand collecting many users' view selectors into a single aggregated selector containing information about who is interested in each part (condenseV), and on the other hand, taking the resulting aggregated views and splitting them into a Map of views for each user (disperseV).
It also specifies the cropV operation which restricts a view to a particular selection, as well as operations for mapping functions over all the leaves of the container.
Nothing
condenseV :: (Foldable t, Filterable t, Functor t) => t (v g) -> v (Compose t g) Source #
Transpose a sufficiently-Map-like structure into a container, effectively aggregating many structures into a single one containing information about which keys each part of it came from originally.
condenseV :: GCondenseView t g v => t (v g) -> v (Compose t g) Source #
Transpose a sufficiently-Map-like structure into a container, effectively aggregating many structures into a single one containing information about which keys each part of it came from originally.
disperseV :: Align t => v (Compose t g) -> t (v g) Source #
Transpose a sufficiently-Map-like structure out of a container, the inverse of condenseV.
disperseV :: GDisperseView t g v => v (Compose t g) -> t (v g) Source #
Transpose a sufficiently-Map-like structure out of a container, the inverse of condenseV.
cropV :: (forall a. s a -> i a -> r a) -> v s -> v i -> Maybe (v r) Source #
Given a structure specifying a query, and a structure representing a view of data, restrict the view to only those parts which satisfy the query. (Essentially intersection of Maps.)
cropV :: forall s i r. GZipView s i r v => (forall a. s a -> i a -> r a) -> v s -> v i -> Maybe (v r) Source #
Given a structure specifying a query, and a structure representing a view of data, restrict the view to only those parts which satisfy the query. (Essentially intersection of Maps.)
We also want a way to determine if the container is empty, because shipping empty containers around is a bad idea.
nullV :: forall i. GMapView i i v => v i -> Bool Source #
We also want a way to determine if the container is empty, because shipping empty containers around is a bad idea.
mapV :: (forall a. f a -> g a) -> v f -> v g Source #
Map a natural transformation over all the leaves of a container, changing the functor which has been applied.
mapV :: GMapView f g v => (forall a. f a -> g a) -> v f -> v g Source #
Map a natural transformation over all the leaves of a container, changing the functor which has been applied.
traverseV :: Applicative m => (forall a. f a -> m (g a)) -> v f -> m (v g) Source #
Traverse over the leaves of a container.
traverseV :: (GMapView f g v, Applicative m) => (forall a. f a -> m (g a)) -> v f -> m (v g) Source #
Traverse over the leaves of a container.
mapMaybeV :: (forall a. f a -> Maybe (g a)) -> v f -> Maybe (v g) Source #
Map over all the leaves of a container, keeping only the Just
results
and returing Nothing
if no leaves are kept.
mapMaybeV :: forall f g. GMapView f g v => (forall a. f a -> Maybe (g a)) -> v f -> Maybe (v g) Source #
Map over all the leaves of a container, keeping only the Just
results
and returing Nothing
if no leaves are kept.
alignWithMaybeV :: (forall a. These (f a) (g a) -> Maybe (h a)) -> v f -> v g -> Maybe (v h) Source #
Map over all the leaves of two containers, combining the leaves with the
provided function, keeping only the Just
results and returing Nothing
if no leaves are kept.
alignWithMaybeV :: forall f g h. GZipView f g h v => (forall a. These (f a) (g a) -> Maybe (h a)) -> v f -> v g -> Maybe (v h) Source #
Map over all the leaves of two containers, combining the leaves with the
provided function, keeping only the Just
results and returing Nothing
if no leaves are kept.
alignWithV :: (forall a. These (f a) (g a) -> h a) -> v f -> v g -> v h Source #
Map over all the leaves of two containers, combining the leaves with the provided function
alignWithV :: GZipView f g h v => (forall a. These (f a) (g a) -> h a) -> v f -> v g -> v h Source #
Map over all the leaves of two containers, combining the leaves with the provided function
Instances
View (Proxy :: (Type -> Type) -> Type) Source # | a completely empty view. |
Defined in Data.Vessel.Class condenseV :: (Foldable t, Filterable t, Functor t) => t (Proxy g) -> Proxy (Compose t g) Source # disperseV :: Align t => Proxy (Compose t g) -> t (Proxy g) Source # cropV :: (forall a. s a -> i a -> r a) -> Proxy s -> Proxy i -> Maybe (Proxy r) Source # nullV :: Proxy i -> Bool Source # mapV :: (forall a. f a -> g a) -> Proxy f -> Proxy g Source # traverseV :: Applicative m => (forall a. f a -> m (g a)) -> Proxy f -> m (Proxy g) Source # mapMaybeV :: (forall a. f a -> Maybe (g a)) -> Proxy f -> Maybe (Proxy g) Source # alignWithMaybeV :: (forall a. These (f a) (g a) -> Maybe (h a)) -> Proxy f -> Proxy g -> Maybe (Proxy h) Source # alignWithV :: (forall a. These (f a) (g a) -> h a) -> Proxy f -> Proxy g -> Proxy h Source # | |
(Has View k, GCompare k) => View (Vessel k) Source # | |
Defined in Data.Vessel.Vessel condenseV :: (Foldable t, Filterable t, Functor t) => t (Vessel k g) -> Vessel k (Compose t g) Source # disperseV :: Align t => Vessel k (Compose t g) -> t (Vessel k g) Source # cropV :: (forall a. s a -> i a -> r a) -> Vessel k s -> Vessel k i -> Maybe (Vessel k r) Source # nullV :: Vessel k i -> Bool Source # mapV :: (forall a. f a -> g a) -> Vessel k f -> Vessel k g Source # traverseV :: Applicative m => (forall a. f a -> m (g a)) -> Vessel k f -> m (Vessel k g) Source # mapMaybeV :: (forall a. f a -> Maybe (g a)) -> Vessel k f -> Maybe (Vessel k g) Source # alignWithMaybeV :: (forall a. These (f a) (g a) -> Maybe (h a)) -> Vessel k f -> Vessel k g -> Maybe (Vessel k h) Source # alignWithV :: (forall a. These (f a) (g a) -> h a) -> Vessel k f -> Vessel k g -> Vessel k h Source # | |
View (SingleV a) Source # | |
Defined in Data.Vessel.Single condenseV :: (Foldable t, Filterable t, Functor t) => t (SingleV a g) -> SingleV a (Compose t g) Source # disperseV :: Align t => SingleV a (Compose t g) -> t (SingleV a g) Source # cropV :: (forall a0. s a0 -> i a0 -> r a0) -> SingleV a s -> SingleV a i -> Maybe (SingleV a r) Source # nullV :: SingleV a i -> Bool Source # mapV :: (forall a0. f a0 -> g a0) -> SingleV a f -> SingleV a g Source # traverseV :: Applicative m => (forall a0. f a0 -> m (g a0)) -> SingleV a f -> m (SingleV a g) Source # mapMaybeV :: (forall a0. f a0 -> Maybe (g a0)) -> SingleV a f -> Maybe (SingleV a g) Source # alignWithMaybeV :: (forall a0. These (f a0) (g a0) -> Maybe (h a0)) -> SingleV a f -> SingleV a g -> Maybe (SingleV a h) Source # alignWithV :: (forall a0. These (f a0) (g a0) -> h a0) -> SingleV a f -> SingleV a g -> SingleV a h Source # | |
View (IdentityV a) Source # | |
Defined in Data.Vessel.Identity condenseV :: (Foldable t, Filterable t, Functor t) => t (IdentityV a g) -> IdentityV a (Compose t g) Source # disperseV :: Align t => IdentityV a (Compose t g) -> t (IdentityV a g) Source # cropV :: (forall a0. s a0 -> i a0 -> r a0) -> IdentityV a s -> IdentityV a i -> Maybe (IdentityV a r) Source # nullV :: IdentityV a i -> Bool Source # mapV :: (forall a0. f a0 -> g a0) -> IdentityV a f -> IdentityV a g Source # traverseV :: Applicative m => (forall a0. f a0 -> m (g a0)) -> IdentityV a f -> m (IdentityV a g) Source # mapMaybeV :: (forall a0. f a0 -> Maybe (g a0)) -> IdentityV a f -> Maybe (IdentityV a g) Source # alignWithMaybeV :: (forall a0. These (f a0) (g a0) -> Maybe (h a0)) -> IdentityV a f -> IdentityV a g -> Maybe (IdentityV a h) Source # alignWithV :: (forall a0. These (f a0) (g a0) -> h a0) -> IdentityV a f -> IdentityV a g -> IdentityV a h Source # | |
GCompare k => View (MonoidalDMap k) Source # | |
Defined in Data.Vessel.Class condenseV :: (Foldable t, Filterable t, Functor t) => t (MonoidalDMap k g) -> MonoidalDMap k (Compose t g) Source # disperseV :: Align t => MonoidalDMap k (Compose t g) -> t (MonoidalDMap k g) Source # cropV :: (forall a. s a -> i a -> r a) -> MonoidalDMap k s -> MonoidalDMap k i -> Maybe (MonoidalDMap k r) Source # nullV :: MonoidalDMap k i -> Bool Source # mapV :: (forall a. f a -> g a) -> MonoidalDMap k f -> MonoidalDMap k g Source # traverseV :: Applicative m => (forall a. f a -> m (g a)) -> MonoidalDMap k f -> m (MonoidalDMap k g) Source # mapMaybeV :: (forall a. f a -> Maybe (g a)) -> MonoidalDMap k f -> Maybe (MonoidalDMap k g) Source # alignWithMaybeV :: (forall a. These (f a) (g a) -> Maybe (h a)) -> MonoidalDMap k f -> MonoidalDMap k g -> Maybe (MonoidalDMap k h) Source # alignWithV :: (forall a. These (f a) (g a) -> h a) -> MonoidalDMap k f -> MonoidalDMap k g -> MonoidalDMap k h Source # | |
GCompare k => View (DMapV k v) Source # | |
Defined in Data.Vessel.DependentMap condenseV :: (Foldable t, Filterable t, Functor t) => t (DMapV k v g) -> DMapV k v (Compose t g) Source # disperseV :: Align t => DMapV k v (Compose t g) -> t (DMapV k v g) Source # cropV :: (forall a. s a -> i a -> r a) -> DMapV k v s -> DMapV k v i -> Maybe (DMapV k v r) Source # nullV :: DMapV k v i -> Bool Source # mapV :: (forall a. f a -> g a) -> DMapV k v f -> DMapV k v g Source # traverseV :: Applicative m => (forall a. f a -> m (g a)) -> DMapV k v f -> m (DMapV k v g) Source # mapMaybeV :: (forall a. f a -> Maybe (g a)) -> DMapV k v f -> Maybe (DMapV k v g) Source # alignWithMaybeV :: (forall a. These (f a) (g a) -> Maybe (h a)) -> DMapV k v f -> DMapV k v g -> Maybe (DMapV k v h) Source # alignWithV :: (forall a. These (f a) (g a) -> h a) -> DMapV k v f -> DMapV k v g -> DMapV k v h Source # | |
(Ord k, View v) => View (SubVessel k v) Source # | |
Defined in Data.Vessel.SubVessel condenseV :: (Foldable t, Filterable t, Functor t) => t (SubVessel k v g) -> SubVessel k v (Compose t g) Source # disperseV :: Align t => SubVessel k v (Compose t g) -> t (SubVessel k v g) Source # cropV :: (forall a. s a -> i a -> r a) -> SubVessel k v s -> SubVessel k v i -> Maybe (SubVessel k v r) Source # nullV :: SubVessel k v i -> Bool Source # mapV :: (forall a. f a -> g a) -> SubVessel k v f -> SubVessel k v g Source # traverseV :: Applicative m => (forall a. f a -> m (g a)) -> SubVessel k v f -> m (SubVessel k v g) Source # mapMaybeV :: (forall a. f a -> Maybe (g a)) -> SubVessel k v f -> Maybe (SubVessel k v g) Source # alignWithMaybeV :: (forall a. These (f a) (g a) -> Maybe (h a)) -> SubVessel k v f -> SubVessel k v g -> Maybe (SubVessel k v h) Source # alignWithV :: (forall a. These (f a) (g a) -> h a) -> SubVessel k v f -> SubVessel k v g -> SubVessel k v h Source # | |
Ord k => View (MapV k v) Source # | |
Defined in Data.Vessel.Map condenseV :: (Foldable t, Filterable t, Functor t) => t (MapV k v g) -> MapV k v (Compose t g) Source # disperseV :: Align t => MapV k v (Compose t g) -> t (MapV k v g) Source # cropV :: (forall a. s a -> i a -> r a) -> MapV k v s -> MapV k v i -> Maybe (MapV k v r) Source # nullV :: MapV k v i -> Bool Source # mapV :: (forall a. f a -> g a) -> MapV k v f -> MapV k v g Source # traverseV :: Applicative m => (forall a. f a -> m (g a)) -> MapV k v f -> m (MapV k v g) Source # mapMaybeV :: (forall a. f a -> Maybe (g a)) -> MapV k v f -> Maybe (MapV k v g) Source # alignWithMaybeV :: (forall a. These (f a) (g a) -> Maybe (h a)) -> MapV k v f -> MapV k v g -> Maybe (MapV k v h) Source # alignWithV :: (forall a. These (f a) (g a) -> h a) -> MapV k v f -> MapV k v g -> MapV k v h Source # |
class View v => EmptyView v where Source #
A type v
supports EmptyView iff it is able to contain no information.
Instances
(Has View k, GCompare k) => EmptyView (Vessel k) Source # | |
Defined in Data.Vessel.Vessel | |
GCompare k => EmptyView (MonoidalDMap k) Source # | |
Defined in Data.Vessel.Class emptyV :: MonoidalDMap k f Source # | |
GCompare k => EmptyView (DMapV k v) Source # | |
Defined in Data.Vessel.DependentMap | |
(Ord k, View v) => EmptyView (SubVessel k v) Source # | |
Defined in Data.Vessel.SubVessel | |
Ord k => EmptyView (MapV k v) Source # | |
Defined in Data.Vessel.Map |
class Selectable v k where Source #
selector :: (forall a. p a) -> k -> v p Source #
Build a query given a suitable value for specifying what we're asking for.
p
will typically be Proxy or Const SelectedCount.
selection :: k -> v Identity -> Selection v k Source #
From a view, extract a more convenient type of value to use.
newtype FlipAp (g :: k) (v :: k -> *) Source #
Instances
Eq (v g) => Eq (FlipAp g v) Source # | |
Ord (v g) => Ord (FlipAp g v) Source # | |
Show (v g) => Show (FlipAp g v) Source # | |
Semigroup (v g) => Semigroup (FlipAp g v) Source # | |
Monoid (v g) => Monoid (FlipAp g v) Source # | |
Group (v g) => Group (FlipAp g v) Source # | |
Additive (v g) => Additive (FlipAp g v) Source # | |
Defined in Data.Vessel.Internal |
newtype IdentityV (a :: *) (g :: * -> *) Source #
A functor-indexed container corresponding to Identity. (i.e. a single non-deletable item)
IdentityV | |
|
Instances
newtype SingleV (a :: *) (g :: * -> *) Source #
A functor-indexed container for a single deletable item.
Instances
A functor-indexed container corresponding to Map k v.
MapV | |
|
Instances
newtype DMapV (k :: * -> *) (v :: * -> *) g Source #
A functor-indexed container corrresponding to DMap k v.
DMapV | |
|
Instances
singletonV :: View v => k v -> v g -> Vessel k g Source #
buildV :: (GCompare k, Has View k, Applicative m) => Vessel k g -> (forall v. k v -> v g -> m (v h)) -> m (Vessel k h) Source #
mapMaybeWithKeyV :: (GCompare k, Has View k) => (forall v. View v => k v -> v g -> Maybe (v g')) -> Vessel k g -> Vessel k g' Source #
traverseWithKeyV :: (GCompare k, Has View k, Applicative m) => (forall v. View v => k v -> v g -> m (v h)) -> Vessel k g -> m (Vessel k h) Source #
traverseWithKeyV_ :: (GCompare k, Has View k, Applicative m) => (forall v. View v => k v -> v g -> m ()) -> Vessel k g -> m () Source #
intersectionWithKeyV :: (GCompare k, Has View k) => (forall v. View v => k v -> v g -> v g' -> v h) -> Vessel k g -> Vessel k g' -> Vessel k h Source #
mapDecomposedV :: (Functor m, View v) => (v Proxy -> m (v Identity)) -> v (Compose (MonoidalMap c) g) -> m (Maybe (v (Compose (MonoidalMap c) Identity))) Source #
alignWithMV :: forall m v f g h. (View v, Applicative m) => (forall a. These (f a) (g a) -> m (h a)) -> v f -> v g -> m (Maybe (v h)) Source #
collapseNullV :: View v => v f -> Maybe (v f) Source #
data VSum (k :: ((* -> *) -> *) -> *) (g :: * -> *) Source #
(k v) :~> (v g) |
module Data.Proxy
module Data.Functor.Identity
module Data.Functor.Const
module Data.Functor.Compose
transposeView :: (View v, Foldable t, Filterable t, Functor t, Align t, QueryResult (t (v g)) ~ t (v g'), QueryResult (v (Compose t g)) ~ v (Compose t g'), Monoid (v g), Monoid (v (Compose t g))) => QueryMorphism (t (v g)) (v (Compose t g)) Source #
A main point of the View class is to be able to produce this QueryMorphism.
class Disperse row where Source #
Disperse is a simplified version of View for ordinary containers. This is used as a stepping stone to obtain the View instance for MapV.
disperse :: (Foldable col, Filterable col, Functor col) => col (row a) -> row (col a) Source #
condense :: Align col => row (col a) -> col (row a) Source #
Instances
Ord k => Disperse (MonoidalMap k) Source # | |
Defined in Data.Vessel.Disperse disperse :: (Foldable col, Filterable col, Functor col) => col (MonoidalMap k a) -> MonoidalMap k (col a) Source # condense :: Align col => MonoidalMap k (col a) -> col (MonoidalMap k a) Source # |
newtype SubVessel (k :: *) (v :: (* -> *) -> *) (f :: * -> *) Source #
Something between MapV and Vessel, where the keys are simple values, but the values are full views.
TODO: this representation has the advantage that all of it's instances come "free", but the mostly "right" representation is probably ... Vessel v (Compose (MonoidalMap k) f)
SubVessel | |
|
Instances
traverseSubVessel :: (Ord k, View v, Applicative m) => (k -> v g -> m (v h)) -> SubVessel k v g -> m (SubVessel k v h) Source #
singletonSubVessel :: forall k f v. View v => k -> v f -> SubVessel k v f Source #