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 PatternSynonyms (available with GHC >= 8.0)
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.NewtypeGCompare tag => Ord (Some tag)Defined in some-1.0.6 · Data.Some.NewtypeGRead f => Read (Some f)Defined in some-1.0.6 · Data.Some.NewtypeGShow tag => Show (Some tag)Defined in some-1.0.6 · Data.Some.NewtypeApplicative m => Semigroup (Some m)Defined in some-1.0.6 · Data.Some.NewtypeApplicative m => Monoid (Some m)Defined in some-1.0.6 · Data.Some.NewtypeGNFData tag => NFData (Some tag)Defined in some-1.0.6 · Data.Some.Newtype