Safe Haskell | None |
---|---|
Language | Haskell2010 |
This is the internal generic-override API and should be considered
unstable and subject to change. This module is exposed for library integrators
(e.g. generic-override-aeson). In general, unless you are integrating
some type class with generic-override, you should prefer to use the
public, stable API provided by Override
.
Synopsis
- newtype Override a (xs :: [*]) = Override a
- unOverride :: Override a xs -> a
- override :: a -> proxy xs -> Override a xs
- data As (o :: k) n
- data With (o :: k) (w :: * -> *)
- newtype Overridden (ms :: Maybe Symbol) a (xs :: [*]) = Overridden a
- unOverridden :: Overridden ms a xs -> a
- overridden :: forall a (ms :: Maybe Symbol) (xs :: [*]) proxy0 proxy1. a -> proxy0 ms -> proxy1 xs -> Overridden ms a xs
- class GOverride (xs :: [*]) (f :: * -> *) where
- type OverrideRep xs f :: * -> *
- overrideFrom :: f x -> OverrideRep xs f x
- overrideTo :: OverrideRep xs f x -> f x
- type family Using (ms :: Maybe Symbol) (x :: *) (xs :: [*]) where ...
Documentation
newtype Override a (xs :: [*]) Source #
The feature of this library. For use with DerivingVia.
Apply it to a type a
and supply a type-level list of instance
overrides xs
.
Override a |
Instances
(Generic (Override a xs), Eq (Rep (Override a xs) ())) => Eq (Override a xs) Source # | |
(Generic (Override a xs), Ord (Rep (Override a xs) ())) => Ord (Override a xs) Source # | |
Defined in Data.Override.Instances compare :: Override a xs -> Override a xs -> Ordering # (<) :: Override a xs -> Override a xs -> Bool # (<=) :: Override a xs -> Override a xs -> Bool # (>) :: Override a xs -> Override a xs -> Bool # (>=) :: Override a xs -> Override a xs -> Bool # | |
(Generic a, GOverride xs (Rep a)) => Generic (Override a xs) Source # | |
(Generic (Override a xs), Semigroup (Rep (Override a xs) ())) => Semigroup (Override a xs) Source # | |
(Generic (Override a xs), Monoid (Rep (Override a xs) ())) => Monoid (Override a xs) Source # | |
type Rep (Override a xs) Source # | |
Defined in Data.Override.Internal |
unOverride :: Override a xs -> a Source #
Unwrap an Override
value.
override :: a -> proxy xs -> Override a xs Source #
Construct an Override
using a proxy of overrides.
data With (o :: k) (w :: * -> *) Source #
Used to wrap a field into a something of kind * -> *
, for example another newtype.
newtype Overridden (ms :: Maybe Symbol) a (xs :: [*]) Source #
Used at the leaf nodes of a generic Rep
Instances
unOverridden :: Overridden ms a xs -> a Source #
Unwrap an Overridden
value.
overridden :: forall a (ms :: Maybe Symbol) (xs :: [*]) proxy0 proxy1. a -> proxy0 ms -> proxy1 xs -> Overridden ms a xs Source #
Same as override
but for Overridden
types.
class GOverride (xs :: [*]) (f :: * -> *) where Source #
type OverrideRep xs f :: * -> * Source #
Analogous to Rep
; rewrites the type for a given Rep
and injects
Overridden
at the leaves.
overrideFrom :: f x -> OverrideRep xs f x Source #
overrideTo :: OverrideRep xs f x -> f x Source #
Instances
(GOverride xs f, GOverride xs g) => GOverride xs (f :*: g) Source # | |
Defined in Data.Override.Internal overrideFrom :: (f :*: g) x -> OverrideRep xs (f :*: g) x Source # overrideTo :: OverrideRep xs (f :*: g) x -> (f :*: g) x Source # | |
GOverride xs (M1 S ('MetaSel ms su ss ds) (K1 R c :: Type -> Type)) Source # | |
Defined in Data.Override.Internal | |
GOverride xs f => GOverride xs (M1 C c f) Source # | |
Defined in Data.Override.Internal overrideFrom :: M1 C c f x -> OverrideRep xs (M1 C c f) x Source # overrideTo :: OverrideRep xs (M1 C c f) x -> M1 C c f x Source # | |
GOverride xs f => GOverride xs (M1 D c f) Source # | |
Defined in Data.Override.Internal overrideFrom :: M1 D c f x -> OverrideRep xs (M1 D c f) x Source # overrideTo :: OverrideRep xs (M1 D c f) x -> M1 D c f x Source # |
type family Using (ms :: Maybe Symbol) (x :: *) (xs :: [*]) where ... Source #
Type family used to determine which override from xs
to replace x
with, if any. The ms
holds the field name
for x
, if applicable.
Using ms x '[] = x | |
Using ms x (As (o :: Symbol) n ': xs) = If (ms == 'Just o) n (Using ms x xs) | |
Using ms x (With (o :: Symbol) w ': xs) = If (ms == 'Just o) (w x) (Using ms x xs) | |
Using ms x (As (o :: *) n ': xs) = If (x == o) n (Using ms x xs) | |
Using ms x (With (o :: *) w ': xs) = If (x == o) (w x) (Using ms x xs) |