| Copyright | (c) 2019 Commonwealth Scientific and Industrial Research Organisation |
|---|---|
| License | BSD3 |
| Maintainer | jack.kelly@data61.csiro.au |
| Stability | experimental |
| Portability | Portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Data.Semialign.Merge
Contents
Description
The Semialign typeclass lets us line up two structures of the same
type. We can use this to merge two structures, or add additional
typeclasses to do filtering, Applicative effects, or tracking
indices.
merge is the simplest function. It takes five arguments: functions
to handle values present in the left / right / both structures and
two structures to merge.
merge :: Semialign t => (a -> c) -> (b -> c) -> (a -> b -> c) -> t a -> t b -> t c
Every other function in this module is a variant with modified functionality based on its name:
- Prefix
imeans an "indexed" variant: each function argument takes an additional index (i) parameter. - Suffix
Maybemeans "filter results": each function argument returnsMaybe c, andNothings are filtered out. - Suffix
Ameans "applicative": each function argument returns actions in someApplicativef, and the whole operation collects these actions to produce the a merged structure inf.
Synopsis
- merge :: Semialign t => (a -> c) -> (b -> c) -> (a -> b -> c) -> t a -> t b -> t c
- mergeMaybe :: (Filterable t, Semialign t) => (a -> Maybe c) -> (b -> Maybe c) -> (a -> b -> Maybe c) -> t a -> t b -> t c
- mergeA :: (Applicative f, Semialign t, Traversable t) => (a -> f c) -> (b -> f c) -> (a -> b -> f c) -> t a -> t b -> f (t c)
- mergeMaybeA :: (Applicative f, Semialign t, Witherable t) => (a -> f (Maybe c)) -> (b -> f (Maybe c)) -> (a -> b -> f (Maybe c)) -> t a -> t b -> f (t c)
- imerge :: SemialignWithIndex i t => (i -> a -> c) -> (i -> b -> c) -> (i -> a -> b -> c) -> t a -> t b -> t c
- imergeMaybe :: (Filterable t, SemialignWithIndex i t) => (i -> a -> Maybe c) -> (i -> b -> Maybe c) -> (i -> a -> b -> Maybe c) -> t a -> t b -> t c
- imergeA :: (Applicative f, SemialignWithIndex i t, Traversable t) => (i -> a -> f c) -> (i -> b -> f c) -> (i -> a -> b -> f c) -> t a -> t b -> f (t c)
- imergeMaybeA :: (Applicative f, SemialignWithIndex i t, Witherable t) => (i -> a -> f (Maybe c)) -> (i -> b -> f (Maybe c)) -> (i -> a -> b -> f (Maybe c)) -> t a -> t b -> f (t c)
Documentation
merge :: Semialign t => (a -> c) -> (b -> c) -> (a -> b -> c) -> t a -> t b -> t c Source #
Since: 0.1.0.0
mergeMaybe :: (Filterable t, Semialign t) => (a -> Maybe c) -> (b -> Maybe c) -> (a -> b -> Maybe c) -> t a -> t b -> t c Source #
Since: 0.1.0.0
mergeA :: (Applicative f, Semialign t, Traversable t) => (a -> f c) -> (b -> f c) -> (a -> b -> f c) -> t a -> t b -> f (t c) Source #
Since: 0.1.0.0
mergeMaybeA :: (Applicative f, Semialign t, Witherable t) => (a -> f (Maybe c)) -> (b -> f (Maybe c)) -> (a -> b -> f (Maybe c)) -> t a -> t b -> f (t c) Source #
Since: 0.1.0.0
Indexed Variants
imerge :: SemialignWithIndex i t => (i -> a -> c) -> (i -> b -> c) -> (i -> a -> b -> c) -> t a -> t b -> t c Source #
Since: 0.1.0.0
imergeMaybe :: (Filterable t, SemialignWithIndex i t) => (i -> a -> Maybe c) -> (i -> b -> Maybe c) -> (i -> a -> b -> Maybe c) -> t a -> t b -> t c Source #
Since: 0.1.0.0
imergeA :: (Applicative f, SemialignWithIndex i t, Traversable t) => (i -> a -> f c) -> (i -> b -> f c) -> (i -> a -> b -> f c) -> t a -> t b -> f (t c) Source #
Since: 0.1.0.0
imergeMaybeA :: (Applicative f, SemialignWithIndex i t, Witherable t) => (i -> a -> f (Maybe c)) -> (i -> b -> f (Maybe c)) -> (i -> a -> b -> f (Maybe c)) -> t a -> t b -> f (t c) Source #
Since: 0.1.0.0