Copyright | (C) 2018 Murat Kasimov |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Murat Kasimov <iokasimov.m@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Get all your structure and rip it apart.
The main idea: if you can describe your data structure via Cofree, with apart you can serialize, persistent or hash a segment of your structure!
A simple introduction to this library can be found here: https://iokasimov.github.io/posts/2018/05/cofree-will-tear-us-apart
- newtype Apart t raw value = Apart {}
- data Shape t raw value
- type family Segment (structure :: Type -> Type) (value :: Type) :: Type where ...
- type family Scattered (structure :: Type -> Type) (value :: Type) (raw :: Type) :: Type where ...
- type Restorer g t raw value = (Traversable t, Applicative g) => raw -> g (Segment (Cofree t) value)
- type Materializer g t raw value = (Traversable t, Applicative g) => Segment (Cofree t) value -> g raw
- recover :: (Traversable t, Applicative g) => Restorer g t raw value -> Scattered (Cofree t) value raw -> g (Cofree t value)
- limit :: (Traversable t, Applicative g) => Int -> Materializer g t raw value -> Cofree t value -> g (Scattered (Cofree t) value raw)
- throughout :: (Traversable t, Monad g) => (value -> g result) -> Restorer g t raw value -> Scattered (Cofree t) value raw -> g (Cofree t result)
- inmemory :: (Functor t, Alternative t) => Apart t raw value -> Cofree t value
Documentation
data Shape t raw value Source #
Type that can tell you about aggregate state of your structure.
Traversable t => Bitraversable (Shape * t) Source # | |
Foldable t => Bifoldable (Shape * t) Source # | |
Functor t => Bifunctor (Shape * t) Source # | |
Functor t => Functor (Shape * t raw) Source # | |
Foldable t => Foldable (Shape * t raw) Source # | |
Traversable t => Traversable (Shape * t raw) Source # | |
Apply t => Apply (Shape * t raw) Source # | |
Alt t => Alt (Shape * t raw) Source # | |
(Show (t value), Show value, Show raw) => Show (Shape * t raw value) Source # | |
type family Segment (structure :: Type -> Type) (value :: Type) :: Type where ... Source #
Segment (Cofree t) value = t (Cofree t value) |
type family Scattered (structure :: Type -> Type) (value :: Type) (raw :: Type) :: Type where ... Source #
type Restorer g t raw value = (Traversable t, Applicative g) => raw -> g (Segment (Cofree t) value) Source #
Pull back segment of values to memory.
type Materializer g t raw value = (Traversable t, Applicative g) => Segment (Cofree t) value -> g raw Source #
Put in-memory values to somewhere else.
recover :: (Traversable t, Applicative g) => Restorer g t raw value -> Scattered (Cofree t) value raw -> g (Cofree t value) Source #
Do nothing with in-memory part, pull back all values of structure to memory.
limit :: (Traversable t, Applicative g) => Int -> Materializer g t raw value -> Cofree t value -> g (Scattered (Cofree t) value raw) Source #
Keep only a certain number of elements in memory, do something with the rest.
throughout :: (Traversable t, Monad g) => (value -> g result) -> Restorer g t raw value -> Scattered (Cofree t) value raw -> g (Cofree t result) Source #
Traverse over scattered structure, including with all restored segments.