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

Modulefcf-containers-0.8.2Haskell2010

Fcf.Data.OldText

Deprecated. Use Fcf.Data.NewText instead

Fcf.Data.OldText

We mimick Data.Text but on type level. The internal representation is based on type level lists. This module is for GHC version 9.0.x or less. The current (as of early 2023) implementation of Fcf.Data.Text will be deprecated and replaced with the contents of Fcf.Data.NewText later 2023 as newer version GHC become more widespread.

  • 47 types
newtypenewtype Text
#

Text is a data structure, that is, a list to hold type-level symbols of length one.

Constructors

Instances36Eval, …

Creation

7 declarations
datadata Empty (a :: Text)
#

Empty

Example
Example1 expression
:kind! (Eval Empty :: Text)(Eval Empty :: Text) :: Text= 'Text ""

See also the other examples in this module.

Instances1Eval
  • type Eval Empty = 'Text ""Defined in fcf-containers-0.8.2 · Fcf.Data.OldText
datadata Singleton (a :: Symbol) (b :: Text)
#

Singleton

Example
Example1 expression
:kind! Eval (Singleton "a")Eval (Singleton "a") :: Text= 'Text "a"
Instances1Eval
datadata FromSymbolList (a :: [Symbol]) (b :: Text)
#

Use FromList to construct a Text from type-level list.

Example

:kind! Eval (FromSymbolList '["h", "e", "l", "l", "u", "r", "e", "i"]) Eval (FromSymbolList '["h", "e", "l", "l", "u", "r", "e", "i"]) :: Text = 'Text "hellurei"

Instances1Eval
datadata ToList (a :: Text) (b :: [Text])
#

Split Text to single character Text list.

Example
Example1 expression
:kind! Eval (ToList =<< FromSymbolList '["a", "b"])Eval (ToList =<< FromSymbolList '["a", "b"]) :: [Text]= '[ 'Text "a", 'Text "b"]
Instances1Eval
datadata ToSymbol (a :: Text) (b :: Symbol)
#

ToSymbol

Example
Example1 expression
:kind! Eval (ToSymbol =<< FromSymbolList '["w", "o", "r", "d"])Eval (ToSymbol =<< FromSymbolList '["w", "o", "r", "d"]) :: Symbol= "word"
Instances1Eval
  • type Eval (ToSymbol ('Text sym)) = symDefined in fcf-containers-0.8.2 · Fcf.Data.OldText
datadata ToSymbolList (a :: Text) (b :: [Symbol])
#

Get the type-level list out of the Text.

Example
Example1 expression
:kind! Eval (ToSymbolList =<< FromSymbolList '["a", "b"])Eval (ToSymbolList =<< FromSymbolList '["a", "b"]) :: [Symbol]= '["a", "b"]
Instances1Eval

Basic Interface

11 declarations
datadata Null (a :: Text) (b :: Bool)
#

Null

Example
Example1 expression
:kind! Eval (Null ('Text "ab"))Eval (Null ('Text "ab")) :: Bool= 'False
Example1 expression
:kind! Eval (Null =<< Empty)Eval (Null =<< Empty) :: Bool= 'True
Instances1Eval
datadata Length (a :: Text) (b :: Nat)
#

Length

Example
Example1 expression
:kind! Eval (Length =<< Singleton "ab")Eval (Length =<< Singleton "ab") :: TL.Natural= 2
Instances1Eval
datadata Append (a :: Text) (b :: Text) (c :: Text)
#

Append two type-level texts.

Example
Example1 expression
:kind! Eval (Append ('Text "aa") ('Text "mu"))Eval (Append ('Text "aa") ('Text "mu")) :: Text= 'Text "aamu"
Instances1Eval
datadata Cons (a :: Symbol) (b :: Text) (c :: Text)
#

Add a symbol to the beginning of a type-level text.

Example
Example1 expression
:kind! Eval (Cons "h" ('Text "aamu"))Eval (Cons "h" ('Text "aamu")) :: Text= 'Text "haamu"
Instances1Eval
datadata Snoc (a :: Text) (b :: Symbol) (c :: Text)
#

Add a symbol to the end of a type-level text.

Example
Example1 expression
:kind! Eval (Snoc ('Text "aam") "u")Eval (Snoc ('Text "aam") "u") :: Text= 'Text "aamu"
Instances1Eval
datadata Uncons (a :: Text) (b :: Maybe (Symbol, Text))
#

Get the first symbol from type-level text.

Example
Example1 expression
:kind! Eval (Uncons ('Text "haamu"))Eval (Uncons ('Text "haamu")) :: Maybe (Symbol, Text)= 'Just '("h", 'Text "aamu")
Example1 expression
:kind! Eval (Uncons ('Text ""))Eval (Uncons ('Text "")) :: Maybe (Symbol, Text)= 'Nothing
Instances1Eval
datadata Unsnoc (a :: Text) (b :: Maybe (Symbol, Text))
#

Get the last symbol from type-level text.

Example
Example1 expression
:kind! Eval (Unsnoc ('Text "aamun"))Eval (Unsnoc ('Text "aamun")) :: Maybe (Symbol, Text)= 'Just '("n", 'Text "aamu")
Example1 expression
:kind! Eval (Unsnoc ('Text ""))Eval (Unsnoc ('Text "")) :: Maybe (Symbol, Text)= 'Nothing
Instances1Eval
datadata Head (a :: Text) (b :: Maybe Symbol)
#

Get the first symbol of type-level text.

Example
Example1 expression
:kind! Eval (Head ('Text "aamu"))Eval (Head ('Text "aamu")) :: Maybe Symbol= 'Just "a"
Example1 expression
:kind! Eval (Head ('Text ""))Eval (Head ('Text "")) :: Maybe Symbol= 'Nothing
Instances1Eval
datadata Tail (a :: Text) (b :: Maybe Text)
#

Get the tail of a type-level text.

Example
Example1 expression
:kind! Eval (Tail ('Text "haamu"))Eval (Tail ('Text "haamu")) :: Maybe Text= 'Just ('Text "aamu")
Example1 expression
:kind! Eval (Tail ('Text ""))Eval (Tail ('Text "")) :: Maybe Text= 'Nothing
Instances1Eval
datadata Init (a :: Text) (b :: Maybe Text)
#

Take all except the last symbol from type-level text.

Example
Example1 expression
:kind! Eval (Init ('Text "aamun"))Eval (Init ('Text "aamun")) :: Maybe Text= 'Just ('Text "aamu")
Example1 expression
:kind! Eval (Init ('Text ""))Eval (Init ('Text "")) :: Maybe Text= 'Nothing
Instances1Eval
datadata CompareLength (a :: Text) (b :: Nat) (c :: Ordering)
#

Compare the length of type-level text to given Nat and give the Ordering.

Example
Example1 expression
:kind! Eval (CompareLength ('Text "aamu") 3)Eval (CompareLength ('Text "aamu") 3) :: Ordering= 'GT
Instances1Eval

Transformation

5 declarations
datadata FMap (a :: Symbol -> Exp Symbol) (b :: Text) (c :: Text)
#

FMap for type-level text.

Example
Example1 expression
:{data IsIsymb :: Symbol -> Exp Booltype instance Eval (IsIsymb s) = Eval ("i" S.== s)data Isymb2e :: Symbol -> Exp Symboltype instance Eval (Isymb2e s) = Eval    (If (IsIsymb @@ s)        (Pure "e")        (Pure s)    ):}
Example1 expression
:kind! Eval (FMap Isymb2e ('Text "imu"))Eval (FMap Isymb2e ('Text "imu")) :: Text= 'Text "emu"
Instances1Eval
datadata Intercalate (a :: Text) (b :: [Text]) (c :: Text)
#

Intercalate for type-level text.

Example
Example1 expression
:kind! Eval (Intercalate ('Text " & ") ('[ 'Text "aamu", 'Text "valo"]))Eval (Intercalate ('Text " & ") ('[ 'Text "aamu", 'Text "valo"])) :: Text= 'Text "aamu & valo"
Instances1Eval
datadata Reverse (a :: Text) (b :: Text)
#

Reverse for type-level text.

Example
Example1 expression
:kind! Eval (Reverse ('Text "aamu"))Eval (Reverse ('Text "aamu")) :: Text= 'Text "umaa"
Example1 expression
:kind! Eval (Reverse =<< Reverse ('Text "aamu"))Eval (Reverse =<< Reverse ('Text "aamu")) :: Text= 'Text "aamu"
Instances1Eval
datadata Replace (a :: Text) (b :: Text) (c :: Text) (d :: Text)
#

Replace for type-level text.

Example
Example1 expression
:kind! Eval (Replace ('Text "tu") ('Text "la") ('Text "tuututtaa"))Eval (Replace ('Text "tu") ('Text "la") ('Text "tuututtaa")) :: Text= 'Text "laulattaa"
Instances1Eval

Special Folds

4 declarations
datadata Concat (a :: [Text]) (b :: Text)
#

Concat for type-level text.

Example
Example1 expression
:kind! Eval (Concat '[ 'Text "la", 'Text "kana"])Eval (Concat '[ 'Text "la", 'Text "kana"]) :: Text= 'Text "lakana"
Instances1Eval
datadata FConcatMap (a :: Symbol -> Exp Text) (b :: Text) (c :: Text)
#

FConcatMap for type-level text.

Example
Example1 expression
:{data IsIsymb :: Symbol -> Exp Booltype instance Eval (IsIsymb s) = Eval ("i" S.== s)data Isymb2aa :: Symbol -> Exp Texttype instance Eval (Isymb2aa s) = Eval    (If (IsIsymb @@ s)        (Pure ('Text "aa"))        (Pure ('Text s))    ):}
Example1 expression
:kind! Eval (FConcatMap Isymb2aa ('Text "imu ih"))Eval (FConcatMap Isymb2aa ('Text "imu ih")) :: Text= 'Text "aamu aah"
Instances1Eval
datadata Any (a :: Symbol -> Exp Bool) (b :: Text) (c :: Bool)
#

Any for type-level text.

Example
Example1 expression
:kind! Eval (Any S.IsDigit ('Text "aamu1"))Eval (Any S.IsDigit ('Text "aamu1")) :: Bool= 'True
Example1 expression
:kind! Eval (Any S.IsDigit ('Text "aamu"))Eval (Any S.IsDigit ('Text "aamu")) :: Bool= 'False
Instances1Eval
datadata All (a :: Symbol -> Exp Bool) (b :: Text) (c :: Bool)
#

All for type-level text.

Example
Example1 expression
:kind! Eval (All S.IsDigit ('Text "aamu1"))Eval (All S.IsDigit ('Text "aamu1")) :: Bool= 'False
Example1 expression
:kind! Eval (All S.IsDigit ('Text "321"))Eval (All S.IsDigit ('Text "321")) :: Bool= 'True
Instances1Eval

Substrings

10 declarations
datadata Take (a :: Nat) (b :: Text) (c :: Text)
#

Take for type-level text.

Example
Example1 expression
:kind! Eval (Take 4 ('Text "aamun"))Eval (Take 4 ('Text "aamun")) :: Text= 'Text "aamu"
Instances1Eval
datadata Drop (a :: Nat) (b :: Text) (c :: Text)
#

Drop for type-level text.

Example
Example1 expression
:kind! Eval (Drop 2 ('Text "aamuna"))Eval (Drop 2 ('Text "aamuna")) :: Text= 'Text "muna"
Instances1Eval
datadata TakeWhile (a :: Symbol -> Exp Bool) (b :: Text) (c :: Text)
#

TakeWhile for type-level text.

Example
Example1 expression
:kind! Eval (TakeWhile (Not <=< S.IsDigit) ('Text "aamu12"))Eval (TakeWhile (Not <=< S.IsDigit) ('Text "aamu12")) :: Text= 'Text "aamu"
Instances1Eval
datadata DropAround (a :: Symbol -> Exp Bool) (b :: Text) (c :: Text)
#

DropAround for type-level text.

Example
Example1 expression
:kind! Eval (DropAround S.IsDigit ('Text "34aamu12"))Eval (DropAround S.IsDigit ('Text "34aamu12")) :: Text= 'Text "aamu"
Instances1Eval
datadata Strip (a :: Text) (b :: Text)
#

Strip the space, newline and tab -symbols from the beginning and and of type-level text.

Example
Example1 expression
:kind! Eval (Strip ('Text "  aamu \n"))Eval (Strip ('Text "  aamu \n")) :: Text= 'Text "aamu"
Instances1Eval

Breaking etc

6 declarations
datadata SplitOn (a :: Text) (b :: Text) (c :: [Text])
#

SplitOn for type-level text.

Example
Example1 expression
:kind! Eval (SplitOn ('Text "ab") ('Text "cdabfgabh"))Eval (SplitOn ('Text "ab") ('Text "cdabfgabh")) :: [Text]= '[ 'Text "cd", 'Text "fg", 'Text "h"]
Instances1Eval
datadata Split (a :: Symbol -> Exp Bool) (b :: Text) (c :: [Text])
#

Split for type-level text.

Example
Example1 expression
:kind! Eval (Split S.IsSpace (Eval (Singleton "cd bf abh")))Eval (Split S.IsSpace (Eval (Singleton "cd bf abh"))) :: [Text]= '[ 'Text "cd", 'Text "bf", 'Text "abh"]
Instances1Eval
datadata Lines (a :: Text) (b :: [Text])
#

Lines for type-level text.

Example
Example1 expression
:kind! Eval (Lines =<< Singleton "ok\nhmm\nab")Eval (Lines =<< Singleton "ok\nhmm\nab") :: [Text]= '[ 'Text "ok", 'Text "hmm", 'Text "ab"]
Instances1Eval
datadata Words (a :: Text) (b :: [Text])
#

Words for type-level text.

Example
Example1 expression
:kind! Eval (Words =<< Singleton "ok hmm\nab")Eval (Words =<< Singleton "ok hmm\nab") :: [Text]= '[ 'Text "ok", 'Text "hmm", 'Text "ab"]
Instances1Eval
datadata Unlines (a :: [Text]) (b :: Text)
#

Unlines for type-level text. This adds a newline to each Text and then concats them.

Example
Example1 expression
:kind! Eval (Unlines '[ 'Text "ok", 'Text "hmm", 'Text "ab"])Eval (Unlines '[ 'Text "ok", 'Text "hmm", 'Text "ab"]) :: Text= 'Text "ok\nhmm\nab\n"
Instances1Eval
datadata Unwords (a :: [Text]) (b :: Text)
#

Unwords for type-level text. This uses Intercalate to add space-symbol between the given texts.

Example
Example1 expression
:kind! Eval (Unwords '[ 'Text "ok", 'Text "hmm", 'Text "ab"])Eval (Unwords '[ 'Text "ok", 'Text "hmm", 'Text "ab"]) :: Text= 'Text "ok hmm ab"
Instances1Eval

Predicates

3 declarations
datadata IsPrefixOf (a :: Text) (b :: Text) (c :: Bool)
#

IsPrefixOf for type-level text.

Example
Example1 expression
:kind! Eval (IsPrefixOf ('Text "aa") ('Text "aamiainen"))Eval (IsPrefixOf ('Text "aa") ('Text "aamiainen")) :: Bool= 'True
Instances1Eval
datadata IsSuffixOf (a :: Text) (b :: Text) (c :: Bool)
#

IsSuffixOf for type-level text.

Example
Example1 expression
:kind! Eval (IsSuffixOf ('Text "nen") ('Text "aamiainen"))Eval (IsSuffixOf ('Text "nen") ('Text "aamiainen")) :: Bool= 'True
Instances1Eval
datadata IsInfixOf (a :: Text) (b :: Text) (c :: Bool)
#

IsInfixOf for type-level text.

Example
Example1 expression
:kind! Eval (IsInfixOf ('Text "mia") ('Text "aamiainen"))Eval (IsInfixOf ('Text "mia") ('Text "aamiainen")) :: Bool= 'True
Instances1Eval