HORIZON HASKELLDocslts/ghc-9.14.x3e2d5682026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 3e2d568 · 2026-10-11

Moduledependent-sum-0.6.2.0Haskell98

Data.Some

  • 1 type
  • 3 values
newtypenewtype Some (tag :: k -> Type)
#

Existential. This is type is useful to hide GADTs' parameters.

Example2 expressions
data Tag :: * -> * where TagInt :: Tag Int; TagBool :: Tag Boolinstance GShow Tag where gshowsPrec _ TagInt = showString "TagInt"; gshowsPrec _ TagBool = showString "TagBool"

You can either use PatternSynonyms

Example2 expressions
let x = Some TagIntxSome TagInt
Example1 expression
case x of { Some TagInt -> "I"; Some TagBool -> "B" } :: String"I"

or you can use functions

Example2 expressions
let y = mkSome TagBoolySome TagBool
Example1 expression
withSome y $ \y' -> case y' of { TagInt -> "I"; TagBool -> "B" } :: String"B"

The implementation of mapSome is safe.

Example2 expressions
let f :: Tag a -> Tag a; f TagInt = TagInt; f TagBool = TagBoolmapSome f ySome TagBool

but you can also use:

Example1 expression
withSome y (mkSome . f)Some TagBool
Instances4Eq, Ord, Read, Show
  • GEq tag => Eq (Some tag)Defined in dependent-sum-0.6.2.0 · Data.Some
  • GCompare tag => Ord (Some tag)Defined in dependent-sum-0.6.2.0 · Data.Some
  • GRead f => Read (Some f)Defined in dependent-sum-0.6.2.0 · Data.Some
  • GShow tag => Show (Some tag)Defined in dependent-sum-0.6.2.0 · Data.Some
patternpattern Some :: tag a -> Some tag
#
patternpattern This :: tag a -> Some tag
#

Deprecated. Use Some instead

valuewithSome :: Some tag -> (forall (a :: k). tag a -> b) -> b
#

Eliminator.