kchO5      !"#$%&'()*+,-./01234Safe'=HIM50-like class for 1-type-parameter GADTs. Unlike 3, this one cannot be mechanically derived from a 5 instance because , must choose the phantom type based on the 6 being parsed.GReadS t is equivalent to +ReadS (forall b. (forall a. t a -> b) -> b)#, which is in turn equivalent to ReadS (Exists t) (with -data Exists t where Exists :: t a -> Exists t)7)-like class for 1-type-parameter GADTs. GShow t => ..." is equivalent to something like (forall a. Show (t a)) => ...R. The easiest way to create instances would probably be to write (or derive) an instance Show (T a), and then simply say: -instance GShow t where gshowsPrec = showsPrec     Safe!"'+234=HIJKM Type class for comparable GADT-like structures. When 2 things are equal, must return a witness that their parameter types are equal as well (). A type for the result of comparing GADT constructors; the type parameters of the GADT values being compared are included so that in the case where they are equal their parameter types can be unified.A class for type-contexts which contain enough information to (at least in some cases) decide the equality of types occurring within them.2Produce a witness of type-equality, if one exists.NA handy idiom for using this would be to pattern-bind in the Maybe monad, eg.: pextract :: GEq tag => tag a -> DSum tag -> Maybe a extract t1 (t2 :=> x) = do Refl <- geq t1 t2 return xOr in a list comprehension: extractMany :: GEq tag => tag a -> [DSum tag] -> [a] extractMany t1 things = [ x | (t2 :=> x) <- things, Refl <- maybeToList (geq t1 t2)](Making use of the DSum type from Data.Dependent.Sum in both examples)JBackwards compatibility alias; as of GHC 7.8, this is the same as `(:~:)`.If f has a M instance, this function makes a suitable default implementation of '(==)'.If f has a M instance, this function makes a suitable default implementation of '(/=)'.TODO: Think of a better name.This operation forgets the phantom types of a   value.         Safe!"'+2346:=HIJKM!In order to compare DSum tag values, tag? must know how to compare both itself and its tagged values. != defines the interface by which they are expected to do so.Continuing the Tag example from the # section, we can define: instance GCompare Tag where gcompare AString AString = GEQ gcompare AString AnInt = GLT gcompare AnInt AString = GGT gcompare AnInt AnInt = GEQ instance OrdTag Tag where compareTagged AString AString = compare compareTagged AnInt AnInt = compareAs with $, "% only needs to consider cases where   returns ."Given two values of type tag a (for which   returns ), return the 8 function for the type a.#In order to test DSum tag for equality, tagI must know how to test both itself and its tagged values for equality. #< defines the interface by which they are expected to do so.Continuing the Tag example from the ) section, we can define: instance GEq Tag where geq AString AString = Just Refl geq AnInt AnInt = Just Refl geq _ _ = Nothing instance EqTag Tag where eqTagged AString AString = (==) eqTagged AnInt AnInt = (==) Note that $f is not called until after the tags have been compared, so it only needs to consider the cases where   returns .$Given two values of type tag a (for which   returns ), return the 9 function for the type a.'In order to make a 7 instance for DSum tag, tagH must be able to show itself as well as any value of the tagged type. H together with this class provides the interface by which it can do so.ShowTag tag => tG is conceptually equivalent to something like this imaginary syntax: ,(forall a. Inhabited (tag a) => Show a) => t , where  InhabitedE is an imaginary predicate that characterizes non-empty types, and a does not occur free in t.The Tag example type introduced in the )1 section could be given the following instances: instance GShow Tag where gshowsPrec _p AString = showString "AString" gshowsPrec _p AnInt = showString "AnInt" instance ShowTag Tag where showTaggedPrec AString = showsPrec showTaggedPrec AnInt = showsPrec(Given a value of type tag a , return the :# function for the type parameter a.)A basic dependent sum type; the first component is a tag that specifies the type of the second; for example, think of a GADT such as: ?data Tag a where AString :: Tag String AnInt :: Tag Int6Then, we have the following valid expressions of type DSum Tag: #AString :=> "hello!" AnInt :=> 42(And we can write functions that consume DSum Tag values by matching, such as: etoString :: DSum Tag -> String toString (AString :=> str) = str toString (AnInt :=> int) = show intBy analogy to the (key => value) construction for dictionary entries in many dynamic languages, we use (key :=> value) as the constructor for dependent sums. The :=> operator has very low precedence and binds to the right, so if the Tag2 GADT is extended with an additional constructor Rec :: Tag (DSum Tag), then Rec :=> AnInt :=> 3 + 4" is parsed as would be expected (Rec :=> (AnInt :=> (3 + 4))) and has type DSum Tag(. Its precedence is just above that of ;, so foo bar $ AString :=> "eep" is equivalent to foo bar (AString :=> "eep").1In order to make a 5 instance for DSum tag, tagI must be able to parse itself as well as any value of the tagged type. H together with this class provides the interface by which it can do so.ReadTag tag => tG is conceptually equivalent to something like this imaginary syntax: ,(forall a. Inhabited (tag a) => Read a) => t , where  InhabitedE is an imaginary predicate that characterizes non-empty types, and a does not occur free in t.The Tag example type introduced in the )1 section could be given the following instances: Kinstance GRead Tag where greadsPrec _p str = case tag of "AString" -> [(\k -> k AString, rest)] "AnInt" -> [(\k -> k AnInt, rest)] _ -> [] where (tag, rest) = break isSpace str instance ReadTag Tag where readTaggedPrec AString = readsPrec readTaggedPrec AnInt = readsPrec!"#$%&'()*+,-./01234 !"#$%&'()*+)*+'(432%&10#$/.!"-,!"#$%&'()*+,-./01234*+<      !"#$%&'()*+,-./0123456789:;<=>?@ABCABD?E=FGdependent-sum-0.3.1.0Data.GADT.CompareData.GADT.ShowData.Dependent.SumbaseData.Type.EqualityRefl:~:GRead greadsPrecGReadSGShow gshowsPrecgshowsgshowgreadsgreadGComparegcompare GOrderingGGTGEQGLTGEqgeq:= defaultEq defaultNeqweakenOrderingdefaultCompare$fGComparek:~:$fGReadkGOrdering$fGShowkGOrdering$fShowGOrdering$fOrdGOrdering $fEqGOrdering $fGEqk:~: $fGReadk:~: $fGShowk:~:OrdTag compareTaggedEqTageqTaggedReadTagreadTaggedPrecShowTagshowTaggedPrecDSum:=>==> $fOrdDSum $fOrdTagk:~:f$fEqDSum $fEqTagk:~:f $fReadDSum$fReadTagk:~:f $fShowDSum$fShowTagkGOrderingf$fShowTagk:~:fGHC.ReadReadGHC.BaseStringGHC.ShowShowghc-prim GHC.Classescompare== showsPrec$