Structural subtype relationship
sub is a (structural) subtype of sup, if its fields are a subset of
those of sup.
Methods
super :: Lens sub sub sup supStructural subtype lens. Given a subtype relationship
sub :< sup, we can focus on thesubstructure ofsup.Example1 expression human ^. super @AnimalAnimal {name = "Tunyasz", age = 50}
Example1 expression set (super @Animal) (Animal "dog" 10) humanHuman {name = "dog", age = 10, address = "London"}
upcast :: sub -> supCast the more specific subtype to the more general supertype
Example1 expression upcast human :: AnimalAnimal {name = "Tunyasz", age = 50}
Example1 expression upcast (upcast human :: Animal) :: Human...... The type 'Animal' is not a subtype of 'Human'.... The following fields are missing from 'Animal':... address...
smash :: sup -> sub -> subPlug a smaller structure into a larger one
Example1 expression smash (Animal "dog" 10) humanHuman {name = "dog", age = 10, address = "London"}
Instances4Subtype
Subtype Void aDefined in generic-lens-2.2.2.0 · Data.Generics.Product.SubtypeUncluttering type signatures (see Void)
Example1 expression :t +d super @Intsuper @Int :: (Subtype Int sub, Functor f) => (Int -> f Int) -> sub -> f sub
Subtype a VoidDefined in generic-lens-2.2.2.0 · Data.Generics.Product.SubtypeUncluttering type signatures (see Void)
Example1 expression :t +d supersuper :: (Subtype sup sub, Functor f) => (sup -> f sup) -> sub -> f sub
Subtype a aDefined in generic-lens-2.2.2.0 · Data.Generics.Product.SubtypeContext a b => Subtype b aDefined in generic-lens-2.2.2.0 · Data.Generics.Product.Subtype