HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulesome-1.0.6Haskell2010

Data.Some.GADT

  • 1 type
  • 6 values
  • Packagesome-1.0.6
  • Exports7
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceGADT.hs
datadata Some (tag :: k -> Type) where
#

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

Example4 expressions
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:

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
Example1 expression
read "Some TagBool" :: Some TagSome TagBool
Example1 expression
read "mkSome TagInt" :: Some TagSome TagInt

Constructors

Instances7Eq, Ord, Read, Show, Semigroup, Monoid, …
valuewithSome :: Some tag -> (forall (a :: k). tag a -> b) -> b
#

Eliminator.

valuemapSome :: (forall (x :: k). f x -> g x) -> Some f -> Some g
#

Map over argument.