Copyright | (c) Ed Wastell 2018 |
---|---|
License | MTL |
Maintainer | edward@wastell.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
A total map from an enum type. Consult the README for more information
Synopsis
- data TotalMap (tag :: *) (a :: *)
- generateAllConstructors :: IsEnumType tag => NP (K tag) (Code tag)
- allTags :: IsEnumType tag => TotalMap tag tag
- getTotalMap :: TotalMap tag a -> tag -> a
- setTotalMap :: forall tag a. IsEnumType tag => TotalMap tag a -> tag -> a -> TotalMap tag a
- ixTotal :: IsEnumType tag => tag -> Lens' (TotalMap tag a) a
- type IsEnumType a = (Generic a, All ([Type] ~ ([] :: [Type])) (Code a))
Documentation
data TotalMap (tag :: *) (a :: *) Source #
A TotalMap
is a total mapping from some enum type tag
to some value a
: it is isomorphic to `tag -> a`. It uses a generics-sop NP
array to store all values, ensuring that every value of tag
must have a corresponding value.
Instances
IsEnumType tag => FunctorWithIndex tag (TotalMap tag) Source # | |
IsEnumType tag => FoldableWithIndex tag (TotalMap tag) Source # | |
Defined in TotalMap ifoldMap :: Monoid m => (tag -> a -> m) -> TotalMap tag a -> m # ifolded :: IndexedFold tag (TotalMap tag a) a # ifoldr :: (tag -> a -> b -> b) -> b -> TotalMap tag a -> b # ifoldl :: (tag -> b -> a -> b) -> b -> TotalMap tag a -> b # ifoldr' :: (tag -> a -> b -> b) -> b -> TotalMap tag a -> b # ifoldl' :: (tag -> b -> a -> b) -> b -> TotalMap tag a -> b # | |
IsEnumType tag => TraversableWithIndex tag (TotalMap tag) Source # | |
Defined in TotalMap itraverse :: Applicative f => (tag -> a -> f b) -> TotalMap tag a -> f (TotalMap tag b) # itraversed :: IndexedTraversal tag (TotalMap tag a) (TotalMap tag b) a b # | |
IsEnumType tag => Monad (TotalMap tag) Source # | |
Functor (TotalMap tag) Source # | |
IsEnumType tag => Applicative (TotalMap tag) Source # | |
Defined in TotalMap | |
Foldable (TotalMap tag) Source # | |
Defined in TotalMap fold :: Monoid m => TotalMap tag m -> m # foldMap :: Monoid m => (a -> m) -> TotalMap tag a -> m # foldr :: (a -> b -> b) -> b -> TotalMap tag a -> b # foldr' :: (a -> b -> b) -> b -> TotalMap tag a -> b # foldl :: (b -> a -> b) -> b -> TotalMap tag a -> b # foldl' :: (b -> a -> b) -> b -> TotalMap tag a -> b # foldr1 :: (a -> a -> a) -> TotalMap tag a -> a # foldl1 :: (a -> a -> a) -> TotalMap tag a -> a # toList :: TotalMap tag a -> [a] # null :: TotalMap tag a -> Bool # length :: TotalMap tag a -> Int # elem :: Eq a => a -> TotalMap tag a -> Bool # maximum :: Ord a => TotalMap tag a -> a # minimum :: Ord a => TotalMap tag a -> a # | |
Traversable (TotalMap tag) Source # | |
Defined in TotalMap | |
IsEnumType tag => Distributive (TotalMap tag) Source # | |
Defined in TotalMap | |
IsEnumType tag => Representable (TotalMap tag) Source # | |
IsEnumType tag => Eq1 (TotalMap tag) Source # | |
(IsEnumType tag, Show tag) => Show1 (TotalMap tag) Source # | |
(IsEnumType tag, Eq a) => Eq (TotalMap tag a) Source # | |
(IsEnumType tag, Show a, Show tag) => Show (TotalMap tag a) Source # | |
type Rep (TotalMap tag) Source # | |
generateAllConstructors :: IsEnumType tag => NP (K tag) (Code tag) Source #
Generate all constructors for some enum type.
TODO: This uses undefined internally as I can not convince the type checker that every constructor has no arguments. This shouldn't be an issue, but feels unsafe so probably should be changed
allTags :: IsEnumType tag => TotalMap tag tag Source #
getTotalMap :: TotalMap tag a -> tag -> a Source #
Extract a value out of a TotalMap
setTotalMap :: forall tag a. IsEnumType tag => TotalMap tag a -> tag -> a -> TotalMap tag a Source #
Replace a value inside a TotalMap