Copyright | (c) Tristan Wibberley 2017 |
---|---|
License | GPL-2 |
Maintainer | tristan.wibberley@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Here is a longer description of this module, containing some
commentary with some markup
.
- data SubZero f g a
- points :: (Functor f, Alternative g) => (a -> Bool) -> f a -> SubZero f g a
- foldlA1 :: (Foldable f, Alternative g) => (a -> a -> a) -> f a -> g a
- letStand :: Alternative f => (a -> Bool) -> a -> f a
- fromSubZero :: Applicative f => f a -> SubZero f Maybe a -> f a
- collapse :: (Functor f, Foldable g, Alternative h) => (a -> a -> a) -> SubZero f g a -> SubZero f h a
Documentation
Converts a functor so that each point at the source has alternatives.
It's just like Compose but the applicative instance appends new alternative values in the rightmost (inner/minor) functor instead of in the leftmost (outer/major) functor.
The result is that two ZipLists of alternatives zip together, providing alternatives to each point and two
Given the immediate utility of this, I do wonder if the Alternative instance of Compose is the wrong one.
f = major functor g = superposition policy - how do they collapse? a = transformed value type
(Functor g, Functor f) => Functor (SubZero f g) Source # | |
(Applicative g, Applicative f) => Applicative (SubZero f g) Source # | |
(Applicative f, Alternative g) => Alternative (SubZero f g) Source # | |
(Eq a, Eq1 g, Eq1 f) => Eq (SubZero f g a) Source # | |
(Ord a, Ord1 g, Ord1 f) => Ord (SubZero f g a) Source # | |
(Read a, Read1 g, Read1 f) => Read (SubZero f g a) Source # | |
(Show a, Show1 g, Show1 f) => Show (SubZero f g a) Source # | |
Constructors and Translators
Constructors are good
:: (Functor f, Alternative g) | |
=> (a -> Bool) | A predicate that indicates whether a point is occupied by its original value or vacant. |
-> f a | The seed points with their values. |
-> SubZero f g a | The constructed |
Turns a container of values to a container of either retained or destroyed values based on a predicate
The type constraint allows us to model possible outcomes so destroyed values are just "no possible outcomes" while retained values represent "the only possible outcome".
To represent that "no value" is a possible outcome, a
should be some type like (Maybe
a) or (Either
String
a).
f
- This functor defines the broad scale behaviours but its Alternative instance is overridden. This in particular might change during upcoming design validation.
g
- This functor supplies the supercedent Alternative instance and thus the finer behaviours.
foldlA1 :: (Foldable f, Alternative g) => (a -> a -> a) -> f a -> g a Source #
letStand :: Alternative f => (a -> Bool) -> a -> f a Source #
fromSubZero :: Applicative f => f a -> SubZero f Maybe a -> f a Source #