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
Context a b => Subtype b aDefined in generic-optics-2.2.1.0 · Data.Generics.Product.SubtypeSubtype Void aDefined in generic-optics-2.2.1.0 · Data.Generics.Product.SubtypeSee Note [Uncluttering type signatures] >>> :t super
Int superInt :: Subtype Int sub => Lens sub sub Int IntSubtype a VoidDefined in generic-optics-2.2.1.0 · Data.Generics.Product.SubtypeSee Note [Uncluttering type signatures] >>> :t super super :: Subtype sup sub => Lens sub sub sup sup
Subtype a aDefined in generic-optics-2.2.1.0 · Data.Generics.Product.Subtype