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

Modulerelude-1.2.0.0Haskell2010

Relude.Extra.Type

SPDX-License-Identifier : MIT Maintainer : Kowainik xrom.xkov@gmail.com Stability : Stable Portability : Portable

Contains useful utilities to work with Types.

  • 1 value
  • Packagerelude-1.2.0.0
  • Exports6
  • LanguageHaskell2010
  • LicenceMIT
  • SourceType.hs
valuetypeName :: Typeable a => Text
#

Gets a string representation of a type.

NOTE: This must be used with TypeApplications language extension.

Example4 expressions
typeName @()"()"typeName @Int"Int"typeName @String"[Char]"typeName @(Maybe Int)"Maybe Int"
familytype family (++) (xs :: [k]) (ys :: [k]) :: [k] where
#

Concatenates type-level lists.

Example1 expression
:kind! '[ 'Just 5, 'Nothing] ++ '[ 'Just 3, 'Nothing, 'Just 1]'[ 'Just 5, 'Nothing] ++ '[ 'Just 3, 'Nothing, 'Just 1] :: [Maybe                                                              Natural]= '[ 'Just 5, 'Nothing, 'Just 3, 'Nothing, 'Just 1]
Example1 expression
:kind! '[] ++ '[ 'Just 3, 'Nothing, 'Just 1]'[] ++ '[ 'Just 3, 'Nothing, 'Just 1] :: [Maybe Natural]= '[ 'Just 3, 'Nothing, 'Just 1]

# 85 "srcReludeExtra/Type.hs"

Equations

  • (++) '[] ys = ys
  • (++) (x ': xs) ys = x ': xs ++ ys
familytype family AllHave (f :: k -> Constraint) (xs :: [k]) :: Constraint where
#

Builds combined Constraint by applying Constraint constructor to all elements of type-level list.

Example1 expression
:kind! AllHave Show '[Int, Text, Double]AllHave Show '[Int, Text, Double] :: Constraint= (Show Int, (Show Text, (Show Double, () :: Constraint)))

which is equivalent to:

(Show Int, Show Text, Show Double) :: Constraint

Equations

familytype family Elem (e :: t) (es :: [t]) :: Bool where
#

Check that a type is an element of a list:

Example1 expression
:kind! Elem String '[]Elem String '[] :: Bool= 'False
Example1 expression
:kind! Elem String '[Int, String]Elem String '[Int, String] :: Bool= 'True
Example1 expression
:kind! Elem String '[Int, Bool]Elem String '[Int, Bool] :: Bool= 'False

Equations

familytype family Fst (t :: k) :: k' where
#

Returns first element of tuple type (with kind *) or type-level tuple (with kind (k1, k2), marked by prefix quote).

Example1 expression
:kind! Maybe (Fst '(Int, Text))Maybe (Fst '(Int, Text)) :: *= Maybe Int
Example1 expression
:kind! Maybe (Fst (Int, Text))Maybe (Fst (Int, Text)) :: *= Maybe Int

Equations

  • Fst '(x, _1) = x
  • Fst (x, _1) = x
familytype family Snd (t :: k) :: k' where
#

Returns second element of tuple type (with kind *) or type-level tuple (with kind (k1, k2), marked by prefix quote).

Example2 expressions
:kind! Maybe (Snd '(Int, Text))Maybe (Snd '(Int, Text)) :: *= Maybe Text:kind! Maybe (Snd (Int, Text))Maybe (Snd (Int, Text)) :: *= Maybe Text

Equations

  • Snd '(_1, y) = y
  • Snd (_1, y) = y