Existential. This is type is useful to hide GADTs' parameters.
data Tag :: * -> * 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 ]
With Church-encoding youcan only use a functions:
let y = mkSome TagBoolymkSome TagBool
withSome y $ \y' -> case y' of { TagInt -> "I"; TagBool -> "B" } :: String"B"
or explicitly work with S
let x = S $ \f -> f TagIntxmkSome TagInt
case x of S f -> f $ \x' -> case x' of { TagInt -> "I"; TagBool -> "B" } :: String"I"
The implementation of mapSome is safe.
let f :: Tag a -> Tag a; f TagInt = TagInt; f TagBool = TagBoolmapSome f ymkSome TagBool
but you can also use:
withSome y (mkSome . f)mkSome TagBool
read "Some TagBool" :: Some TagmkSome TagBool
read "mkSome TagInt" :: Some TagmkSome TagInt
Instances6Eq, Ord, Read, Show, Semigroup, Monoid
GEq tag => Eq (Some tag)Defined in some-1.0.6 · Data.GADT.InternalGCompare tag => Ord (Some tag)Defined in some-1.0.6 · Data.GADT.InternalGRead f => Read (Some f)Defined in some-1.0.6 · Data.GADT.InternalGShow tag => Show (Some tag)Defined in some-1.0.6 · Data.GADT.InternalApplicative m => Semigroup (Some m)Defined in some-1.0.6 · Data.GADT.InternalApplicative m => Monoid (Some m)Defined in some-1.0.6 · Data.GADT.Internal