-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Helps when going "seed values" -> alternatives and optional -> answers -- --
---- -- Types to support turning structured collections of seed values into -- the same structures with alternatives along with some functions for -- regular uses. Please see README.md for more information @package subzero @version 0.1.0.8 module Data.Map.IMap -- | An applicative map that discards mismatched keys ie, it uses -- intersection for it's applicative instance -- -- It has a case in which every key is occupied and equal data IMap m v -- | A class for maps so IMap can be generic class IsMap m where type Key m where { type family Key m; } fromList :: IsMap m => [(Key m, v)] -> m v intersectionWith :: IsMap m => (a -> b -> c) -> m a -> m b -> m c mapmap :: IsMap m => (a -> b) -> m a -> m b fromList :: IsMap m => [(Key m, v)] -> m v intersectionWith :: IsMap m => (a -> b -> c) -> m a -> m b -> m c mapmap :: IsMap m => (a -> b) -> m a -> m b instance (GHC.Classes.Eq (m v), GHC.Classes.Eq v) => GHC.Classes.Eq (Data.Map.IMap.IMap m v) instance (GHC.Show.Show (m v), GHC.Show.Show v) => GHC.Show.Show (Data.Map.IMap.IMap m v) instance GHC.Classes.Ord k => Data.Map.IMap.IsMap (Data.Map.Base.Map k) instance Data.Map.IMap.IsMap Data.IntMap.Base.IntMap instance Data.Map.IMap.IsMap m => Data.Map.IMap.IsMap (Data.Map.IMap.IMap m) instance Data.Map.IMap.IsMap m => GHC.Base.Functor (Data.Map.IMap.IMap m) instance Data.Map.IMap.IsMap m => GHC.Base.Applicative (Data.Map.IMap.IMap m) -- | Converts a functor so that each point at the source has alternatives -- to model things like a container of optional values, or of a variety -- of opinions about a point. -- -- It turns out that Compose is ideal for this because -- Functor f => f a is isomorphic to -- Functor f => Compose f Identity a. -- -- The gorgeous result is that two ZipLists of -- alternatives can zip together, providing an expanding set of -- alternatives to each point. -- -- Here's how you can interpret Compose f g a: -- --
-- collapse f empty = simplify empty ---- --
-- collapse f (pure x) = simplify (pure x) ---- --
-- collapse f (x <|> y) = pure (f x y) ---- -- g must form a monoid under f when -- empty is the monoid's identity. class (Applicative g, Applicative h) => Superposition g h -- | Tries to convert from one alternative to another simplify :: Superposition g h => g a -> Maybe (h a) -- | Combines many alternatives into one using a function parameter. -- empty stays empty. This is quite free -- in the type of the result so the user can choose whether to keep the -- same type to re-expand the structure or to transform to a smaller type -- to avoid relying on instances for certain behaviours. collapse :: Superposition g h => (a -> a -> a) -> g a -> h a -- | Tries to convert from one alternative to another simplify :: Superposition g h => g a -> Maybe (h a) -- | Combines many alternatives into one using a function parameter. -- empty stays empty. This is quite free -- in the type of the result so the user can choose whether to keep the -- same type to re-expand the structure or to transform to a smaller type -- to avoid relying on instances for certain behaviours. collapse :: Superposition g h => (a -> a -> a) -> g a -> h a -- | Turns a value "a" to Just a or -- Nothing based on a predicate assuming you use it in a -- context that wants Maybe a instead of some other -- representation of Alternatives keep :: (Alternative f) => (a -> Bool) -> a -> f a -- | Does the same as keep for values at the other end of -- Identity. -- --
-- keep = (keepIdentity . Identity) f --keepIdentity :: (Alternative f) => (a -> Bool) -> Identity a -> f a instance GHC.Base.Alternative h => Control.Applicative.SubZero.Superposition [] h instance (GHC.Base.Applicative f, Control.Applicative.SubZero.Superposition g h) => Control.Applicative.SubZero.Superposition (Data.Functor.Compose.Compose f g) (Data.Functor.Compose.Compose f h) -- | Here is a longer description of this module, containing some -- commentary with some markup. module Control.Applicative.SubZero.Examples -- | Takes values in an Applicative and returns the fizzbuzz -- game's answer for that value. Caution regular lists will -- not do what you want, use: -- -- fizzbuzz :: (Integral a, Show a, Applicative f) => f a -> f String