subzero-0.1.0.0: Helps when going "seed values" -> alternatives and optional -> answers

Copyright(c) Tristan Wibberley 2017
LicenseGPL-2
Maintainertristan.wibberley@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Control.Applicative.SubZero

Contents

Description

Here is a longer description of this module, containing some commentary with some markup.

Synopsis

Documentation

data SubZero f g a Source #

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

Instances

(Functor g, Functor f) => Functor (SubZero f g) Source # 

Methods

fmap :: (a -> b) -> SubZero f g a -> SubZero f g b #

(<$) :: a -> SubZero f g b -> SubZero f g a #

(Applicative g, Applicative f) => Applicative (SubZero f g) Source # 

Methods

pure :: a -> SubZero f g a #

(<*>) :: SubZero f g (a -> b) -> SubZero f g a -> SubZero f g b #

(*>) :: SubZero f g a -> SubZero f g b -> SubZero f g b #

(<*) :: SubZero f g a -> SubZero f g b -> SubZero f g a #

(Applicative f, Alternative g) => Alternative (SubZero f g) Source # 

Methods

empty :: SubZero f g a #

(<|>) :: SubZero f g a -> SubZero f g a -> SubZero f g a #

some :: SubZero f g a -> SubZero f g [a] #

many :: SubZero f g a -> SubZero f g [a] #

(Eq a, Eq1 g, Eq1 f) => Eq (SubZero f g a) Source # 

Methods

(==) :: SubZero f g a -> SubZero f g a -> Bool #

(/=) :: SubZero f g a -> SubZero f g a -> Bool #

(Ord a, Ord1 g, Ord1 f) => Ord (SubZero f g a) Source # 

Methods

compare :: SubZero f g a -> SubZero f g a -> Ordering #

(<) :: SubZero f g a -> SubZero f g a -> Bool #

(<=) :: SubZero f g a -> SubZero f g a -> Bool #

(>) :: SubZero f g a -> SubZero f g a -> Bool #

(>=) :: SubZero f g a -> SubZero f g a -> Bool #

max :: SubZero f g a -> SubZero f g a -> SubZero f g a #

min :: SubZero f g a -> SubZero f g a -> SubZero f g a #

(Read a, Read1 g, Read1 f) => Read (SubZero f g a) Source # 

Methods

readsPrec :: Int -> ReadS (SubZero f g a) #

readList :: ReadS [SubZero f g a] #

readPrec :: ReadPrec (SubZero f g a) #

readListPrec :: ReadPrec [SubZero f g a] #

(Show a, Show1 g, Show1 f) => Show (SubZero f g a) Source # 

Methods

showsPrec :: Int -> SubZero f g a -> ShowS #

show :: SubZero f g a -> String #

showList :: [SubZero f g a] -> ShowS #

Constructors and Translators

Constructors are good

points Source #

Arguments

:: (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 SubZero value.

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 #

collapse :: (Functor f, Foldable g, Alternative h) => (a -> a -> a) -> SubZero f g a -> SubZero f h a Source #