Existential. This is type is useful to hide GADTs' parameters.
data Tag :: Type -> Type where TagInt :: Tag Int; TagBool :: Tag Boolinstance GShow Tag where gshowsPrec _ TagInt = showString "TagInt"; gshowsPrec _ TagBool = showString "TagBool"classify s = case s of "TagInt" -> [mkGReadResult TagInt]; "TagBool" -> [mkGReadResult TagBool]; _ -> []instance GRead Tag where greadsPrec _ s = [ (r, rest) | (con, rest) <- lex s, r <- classify con ]
You can either use constructor:
let x = Some TagIntxSome TagInt
case x of { Some TagInt -> "I"; Some TagBool -> "B" } :: String"I"
or you can use functions
let y = mkSome TagBoolySome TagBool
withSome y $ \y' -> case y' of { TagInt -> "I"; TagBool -> "B" } :: String"B"
The implementation of mapSome is safe.
let f :: Tag a -> Tag a; f TagInt = TagInt; f TagBool = TagBoolmapSome f ySome TagBool
but you can also use:
withSome y (mkSome . f)Some TagBool
read "Some TagBool" :: Some TagSome TagBool
read "mkSome TagInt" :: Some TagSome TagInt
Instances7Eq, Ord, Read, Show, Semigroup, Monoid, …
GEq tag => Eq (Some tag)Defined in some-1.0.6 · Data.Some.GADTGCompare tag => Ord (Some tag)Defined in some-1.0.6 · Data.Some.GADTGRead f => Read (Some f)Defined in some-1.0.6 · Data.Some.GADTGShow tag => Show (Some tag)Defined in some-1.0.6 · Data.Some.GADTApplicative m => Semigroup (Some m)Defined in some-1.0.6 · Data.Some.GADTApplicative m => Monoid (Some m)Defined in some-1.0.6 · Data.Some.GADTGNFData tag => NFData (Some tag)Defined in some-1.0.6 · Data.Some.GADT