HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulesome-1.0.6Haskell2010

Data.Some.Church

  • 1 type
  • 5 values
  • Packagesome-1.0.6
  • Exports6
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceInternal.hs
newtypenewtype Some (tag :: k -> Type)
#

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

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

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

or explicitly work with S

Example2 expressions
let x = S $ \f -> f TagIntxmkSome TagInt
Example1 expression
case x of S f -> f $ \x' -> case x' of { TagInt -> "I"; TagBool -> "B" } :: String"I"

The implementation of mapSome is safe.

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

but you can also use:

Example1 expression
withSome y (mkSome . f)mkSome TagBool
Example1 expression
read "Some TagBool" :: Some TagmkSome TagBool
Example1 expression
read "mkSome TagInt" :: Some TagmkSome TagInt

Constructors

  • S
    • withSome :: forall r. (forall (a :: k). tag a -> r) -> r

      Eliminator.

Instances6Eq, Ord, Read, Show, Semigroup, Monoid
valuemapSome :: (forall (x :: k). f x -> g x) -> Some f -> Some g
#

Map over argument.