Copyright | (c) gspia 2020- |
---|---|
License | BSD |
Maintainer | gspia |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Fcf.Data.NewText
We mimick Data.Text but on type level. The current internal representation of Fcf.Data.Text is based on type level lists. The current (as of early 2023) implementation of this Fcf.Data.Text will be deprecated and replaced with the contents of Fcf.Data.NewText later 2023 as newer version GHC become more widespread.
The old version working with 9.0.x or less will be kept at Fcf.Data.OldText for some time. Similarly, the module Fcf.Data.NewText contains the functions and definitions for better Text type, which will be taken into use after some time.
The Fcf.Data.NewText will replace Fcf.Data.Text eventually.
Synopsis
- data Text = Text Symbol
- data Empty :: Exp Text
- data Singleton :: Char -> Exp Text
- data FromList :: [Text] -> Exp Text
- data FromSymbolList :: [Symbol] -> Exp Text
- data FromSymbol :: Symbol -> Exp Text
- data ToList :: Text -> Exp [Text]
- data ToSymbolList :: Text -> Exp [Symbol]
- data ToCharList :: Text -> Exp [Char]
- data Unpack :: Text -> Exp Symbol
- data Null :: Text -> Exp Bool
- data Length :: Text -> Exp Nat
- data Append :: Text -> Text -> Exp Text
- data Cons :: Char -> Text -> Exp Text
- data ConsSymbol :: Symbol -> Text -> Exp Text
- data Snoc :: Text -> Char -> Exp Text
- data SnocSymbol :: Text -> Symbol -> Exp Text
- data Uncons :: Text -> Exp (Maybe (Char, Text))
- data Unsnoc :: Text -> Exp (Maybe (Text, Char))
- data Head :: Text -> Exp (Maybe Char)
- data Last :: Text -> Exp (Maybe Char)
- data Tail :: Text -> Exp (Maybe Text)
- data Init :: Text -> Exp (Maybe Text)
- data CompareLength :: Text -> Nat -> Exp Ordering
- data FMap :: (Char -> Exp Char) -> Text -> Exp Text
- data FMapSymbol :: (Symbol -> Exp Symbol) -> Text -> Exp Text
- data FMapT :: (Text -> Exp Text) -> Text -> Exp Text
- data Intercalate :: Text -> [Text] -> Exp Text
- data Intersperse :: Char -> Text -> Exp Text
- data IntersperseSymbol :: Symbol -> Text -> Exp Text
- data Reverse :: Text -> Exp Text
- data Replace :: Text -> Text -> Text -> Exp Text
- data Concat :: [Text] -> Exp Text
- data ConcatMap :: (Char -> Exp Text) -> Text -> Exp Text
- data ConcatMapSymbol :: (Symbol -> Exp Text) -> Text -> Exp Text
- data ConcatMapCS :: (Char -> Exp Symbol) -> Text -> Exp Text
- data Any :: (Char -> Exp Bool) -> Text -> Exp Bool
- data AnySymbol :: (Symbol -> Exp Bool) -> Text -> Exp Bool
- data All :: (Char -> Exp Bool) -> Text -> Exp Bool
- data AllSymbol :: (Symbol -> Exp Bool) -> Text -> Exp Bool
- data Take :: Nat -> Text -> Exp Text
- data TakeEnd :: Nat -> Text -> Exp Text
- data Drop :: Nat -> Text -> Exp Text
- data DropEnd :: Nat -> Text -> Exp Text
- data TakeWhile :: (Char -> Exp Bool) -> Text -> Exp Text
- data TakeWhileSymbol :: (Symbol -> Exp Bool) -> Text -> Exp Text
- data TakeWhileEnd :: (Char -> Exp Bool) -> Text -> Exp Text
- data TakeWhileEndSymbol :: (Symbol -> Exp Bool) -> Text -> Exp Text
- data DropWhile :: (Char -> Exp Bool) -> Text -> Exp Text
- data DropWhileEnd :: (Char -> Exp Bool) -> Text -> Exp Text
- data DropWhileEndSymbol :: (Symbol -> Exp Bool) -> Text -> Exp Text
- data DropAround :: (Char -> Exp Bool) -> Text -> Exp Text
- data DropAroundSymbol :: (Symbol -> Exp Bool) -> Text -> Exp Text
- data Strip :: Text -> Exp Text
- data SplitOn :: Text -> Text -> Exp [Text]
- data Split :: (Char -> Exp Bool) -> Text -> Exp [Text]
- data Lines :: Text -> Exp [Text]
- data Words :: Text -> Exp [Text]
- data Unlines :: [Text] -> Exp Text
- data Unwords :: [Text] -> Exp Text
- data IsPrefixOf :: Text -> Text -> Exp Bool
- data IsSuffixOf :: Text -> Text -> Exp Bool
- data IsInfixOf :: Text -> Text -> Exp Bool
Documentation
Text
is a data structure, that is, a list to hold type-level symbols of
length one.
Instances
Creation
data Empty :: Exp Text Source #
Empty
Example
>>>
:kind! (Eval Empty :: Text)
(Eval Empty :: Text) :: Text = 'Text ""
See also the other examples in this module.
data Singleton :: Char -> Exp Text Source #
Singleton
>>>
:kind! Eval (Singleton 'a')
Eval (Singleton 'a') :: Text = 'Text "a"
data FromSymbolList :: [Symbol] -> Exp Text Source #
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"
Instances
type Eval (FromSymbolList sym :: Text -> Type) Source # | |
Defined in Fcf.Data.NewText |
data FromSymbol :: Symbol -> Exp Text Source #
FromSymbol
Example
>>>
:kind! Eval (FromSymbol "some text")
Eval (FromSymbol "some text") :: Text = 'Text "some text"
Instances
type Eval (FromSymbol s :: Text -> Type) Source # | |
Defined in Fcf.Data.NewText |
data ToList :: Text -> Exp [Text] Source #
Split text to characters and give them as Text list.
:kind! Eval (ToList =<< FromSymbol "abc")
Eval (ToList =<< FromSymbol "abc") :: [Text] = '[ 'Text "a", 'Text "b", 'Text "c"]
data ToSymbolList :: Text -> Exp [Symbol] Source #
Get the type-level list out of the Text
.
Example
>>>
:kind! Eval (ToSymbolList =<< FromSymbolList '["a", "b"])
Eval (ToSymbolList =<< FromSymbolList '["a", "b"]) :: [Symbol] = '["a", "b"]
Instances
type Eval (ToSymbolList ('Text sym) :: [Symbol] -> Type) Source # | |
Defined in Fcf.Data.NewText type Eval (ToSymbolList ('Text sym) :: [Symbol] -> Type) = Eval (FMap CharToSymbol =<< ToCharList sym) |
data ToCharList :: Text -> Exp [Char] Source #
Split text to characters and give them as Char list.
:kind! Eval (ToCharList =<< FromSymbol "abc")
Eval (ToCharList =<< FromSymbol "abc") :: [Char]
= '[a
, b
, c
]
Instances
type Eval (ToCharList ('Text sym) :: [Char] -> Type) Source # | |
Defined in Fcf.Data.NewText |
data Unpack :: Text -> Exp Symbol Source #
Unpack
Example
>>>
:kind! Eval (Unpack =<< FromSymbol "word")
Eval (Unpack =<< FromSymbol "word") :: Symbol = "word"
Basic Interface
data Null :: Text -> Exp Bool Source #
Null
Example
>>>
:kind! Eval (Null ('Text "ab"))
Eval (Null ('Text "ab")) :: Bool = 'False
>>>
:kind! Eval (Null =<< Empty)
Eval (Null =<< Empty) :: Bool = 'True
data Length :: Text -> Exp Nat Source #
Length
Example
>>>
:kind! Eval (Length =<< FromSymbol "ab")
Eval (Length =<< FromSymbol "ab") :: TL.Natural = 2
data Append :: Text -> Text -> Exp Text Source #
Append two type-level texts.
Example
>>>
:kind! Eval (Append ('Text "aa") ('Text "mu"))
Eval (Append ('Text "aa") ('Text "mu")) :: Text = 'Text "aamu"
data Cons :: Char -> Text -> Exp Text Source #
Add a Char to the beginning of a type-level text.
Example
>>>
:kind! Eval (Cons 'h' ('Text "aamu"))
Eval (Cons 'h' ('Text "aamu")) :: Text = 'Text "haamu"
data ConsSymbol :: Symbol -> Text -> Exp Text Source #
Add a Symbol to the beginning of a type-level text.
Example
>>>
:kind! Eval (ConsSymbol "h" ('Text "aamu"))
Eval (ConsSymbol "h" ('Text "aamu")) :: Text = 'Text "haamu"
Instances
type Eval (ConsSymbol s ('Text sym) :: Text -> Type) Source # | |
Defined in Fcf.Data.NewText |
data Snoc :: Text -> Char -> Exp Text Source #
Add a Char to the end of a type-level text.
Example
>>>
:kind! Eval (Snoc ('Text "aam") 'u')
Eval (Snoc ('Text "aam") 'u') :: Text = 'Text "aamu"
data SnocSymbol :: Text -> Symbol -> Exp Text Source #
Add a Symbol to the end of a type-level text.
Example
>>>
:kind! Eval (SnocSymbol ('Text "aam") "u")
Eval (SnocSymbol ('Text "aam") "u") :: Text = 'Text "aamu"
Instances
type Eval (SnocSymbol ('Text sym) s :: Text -> Type) Source # | |
Defined in Fcf.Data.NewText |
data Uncons :: Text -> Exp (Maybe (Char, Text)) Source #
Get the first Char from type-level text.
Example
>>>
:kind! Eval (Uncons ('Text "haamu"))
Eval (Uncons ('Text "haamu")) :: Maybe (Char, Text) = 'Just '('h', 'Text "aamu")
>>>
:kind! Eval (Uncons ('Text ""))
Eval (Uncons ('Text "")) :: Maybe (Char, Text) = 'Nothing
data Unsnoc :: Text -> Exp (Maybe (Text, Char)) Source #
Get the last Char from type-level text.
Example
>>>
:kind! Eval (Unsnoc ('Text "aamun"))
Eval (Unsnoc ('Text "aamun")) :: Maybe (Text, Char) = 'Just '( 'Text "aamu", 'n')
>>>
:kind! Eval (Unsnoc ('Text ""))
Eval (Unsnoc ('Text "")) :: Maybe (Text, Char) = 'Nothing
data Head :: Text -> Exp (Maybe Char) Source #
Get the first Char of type-level text.
Example
>>>
:kind! Eval (Head ('Text "aamu"))
Eval (Head ('Text "aamu")) :: Maybe Char = 'Just 'a'
>>>
:kind! Eval (Head ('Text ""))
Eval (Head ('Text "")) :: Maybe Char = 'Nothing
data Last :: Text -> Exp (Maybe Char) Source #
Get the last Char of type-level text.
Example
>>>
:kind! Eval (Last ('Text "aamu"))
Eval (Last ('Text "aamu")) :: Maybe Char = 'Just 'u'
>>>
:kind! Eval (Last ('Text ""))
Eval (Last ('Text "")) :: Maybe Char = 'Nothing
data Tail :: Text -> Exp (Maybe Text) Source #
Get the tail of a type-level text.
Example
>>>
:kind! Eval (Tail ('Text "haamu"))
Eval (Tail ('Text "haamu")) :: Maybe Text = 'Just ('Text "aamu")
>>>
:kind! Eval (Tail ('Text ""))
Eval (Tail ('Text "")) :: Maybe Text = 'Nothing
data Init :: Text -> Exp (Maybe Text) Source #
Take all except the last Char from type-level text.
Example
>>>
:kind! Eval (Init ('Text "aamun"))
Eval (Init ('Text "aamun")) :: Maybe Text = 'Just ('Text "aamu")
>>>
:kind! Eval (Init ('Text ""))
Eval (Init ('Text "")) :: Maybe Text = 'Nothing
data CompareLength :: Text -> Nat -> Exp Ordering Source #
Compare the length of type-level text to given Nat and give the Ordering.
Example
>>>
:kind! Eval (CompareLength ('Text "aamu") 3)
Eval (CompareLength ('Text "aamu") 3) :: Ordering = 'GT
Instances
type Eval (CompareLength txt n :: Ordering -> Type) Source # | |
Defined in Fcf.Data.NewText |
Transformation
data FMap :: (Char -> Exp Char) -> Text -> Exp Text Source #
FMap for type-level text.
Example
>>>
:{
data DigitsToX :: Char -> Exp Char type instance Eval (DigitsToX c) = Eval (If (IsDigit @@ c) (Pure 'X') (Pure c) ) :}
>>>
:kind! Eval (FMap DigitsToX ('Text "Some4text5oh9."))
Eval (FMap DigitsToX ('Text "Some4text5oh9.")) :: Text = 'Text "SomeXtextXohX."
data FMapSymbol :: (Symbol -> Exp Symbol) -> Text -> Exp Text Source #
FMapSymbol for type-level text.
Example
>>>
:{
data IsIsymb :: Symbol -> Exp Bool type instance Eval (IsIsymb s) = Eval ("i" Sym.== s) data Isymb2e :: Symbol -> Exp Symbol type instance Eval (Isymb2e s) = Eval (If (IsIsymb @@ s) (Pure "e") (Pure s) ) :}
>>>
:kind! Eval (FMapSymbol Isymb2e ('Text "imu"))
Eval (FMapSymbol Isymb2e ('Text "imu")) :: Text = 'Text "emu"
data Intercalate :: Text -> [Text] -> Exp Text Source #
Intercalate for type-level text.
Example
>>>
:kind! Eval (Intercalate ('Text " & ") ('[ 'Text "aamu", 'Text "valo"]))
Eval (Intercalate ('Text " & ") ('[ 'Text "aamu", 'Text "valo"])) :: Text = 'Text "aamu & valo"
Instances
type Eval (Intercalate txt txts :: Text -> Type) Source # | |
Defined in Fcf.Data.NewText |
data Intersperse :: Char -> Text -> Exp Text Source #
Intersperse Char for type-level text.
Example
>>>
:kind! Eval (Intersperse '.' ('Text "aamu"))
Eval (Intersperse '.' ('Text "aamu")) :: Text = 'Text "a.a.m.u"
Instances
type Eval (Intersperse c ('Text sym) :: Text -> Type) Source # | |
Defined in Fcf.Data.NewText type Eval (Intersperse c ('Text sym) :: Text -> Type) = Eval (FromSymbolList =<< (Intersperse (CharToSymbol @@ c) =<< (FMap CharToSymbol =<< ToCharList sym))) |
data IntersperseSymbol :: Symbol -> Text -> Exp Text Source #
Intersperse Symbol for type-level text.
Example
>>>
:kind! Eval (IntersperseSymbol "." ('Text "aamu"))
Eval (IntersperseSymbol "." ('Text "aamu")) :: Text = 'Text "a.a.m.u"
Instances
type Eval (IntersperseSymbol s ('Text sym) :: Text -> Type) Source # | |
Defined in Fcf.Data.NewText type Eval (IntersperseSymbol s ('Text sym) :: Text -> Type) = Eval (FromSymbolList =<< (Intersperse s =<< (FMap CharToSymbol =<< ToCharList sym))) |
data Reverse :: Text -> Exp Text Source #
Reverse for type-level text.
Example
>>>
:kind! Eval (Reverse ('Text "aamu"))
Eval (Reverse ('Text "aamu")) :: Text = 'Text "umaa"
>>>
:kind! Eval (Reverse =<< Reverse ('Text "aamu"))
Eval (Reverse =<< Reverse ('Text "aamu")) :: Text = 'Text "aamu"
data Replace :: Text -> Text -> Text -> Exp Text Source #
Replace for type-level text.
Example
>>>
:kind! Eval (Replace ('Text "tu") ('Text "la") ('Text "tuututtaa"))
Eval (Replace ('Text "tu") ('Text "la") ('Text "tuututtaa")) :: Text = 'Text "laulattaa"
Special Folds
data Concat :: [Text] -> Exp Text Source #
Concat for type-level text.
Example
>>>
:kind! Eval (Concat '[ 'Text "la", 'Text "kana"])
Eval (Concat '[ 'Text "la", 'Text "kana"]) :: Text = 'Text "lakana"
data ConcatMap :: (Char -> Exp Text) -> Text -> Exp Text Source #
ConcatMap for type-level text. This takes Char to Text function.
Example
>>>
:{
data DigitsToHoo :: Char -> Exp Text type instance Eval (DigitsToHoo c) = Eval (If (IsDigit @@ c) (Pure ( 'Text "hoo")) (Singleton c) ) :}
>>>
:kind! Eval (ConcatMap DigitsToHoo ('Text "haa2hui2"))
Eval (ConcatMap DigitsToHoo ('Text "haa2hui2")) :: Text = 'Text "haahoohuihoo"
data ConcatMapSymbol :: (Symbol -> Exp Text) -> Text -> Exp Text Source #
FConcatMapSymbol for type-level text. This takes Symbol to Text function.
Example
>>>
:{
data IsIsymb :: Symbol -> Exp Bool type instance Eval (IsIsymb s) = Eval ("i" Sym.== s) data Isymb2aa :: Symbol -> Exp Text type instance Eval (Isymb2aa s) = Eval (If (IsIsymb @@ s) (Pure ('Text "aa")) (Pure ('Text s)) ) :}
>>>
:kind! Eval (ConcatMapSymbol Isymb2aa ('Text "imu ih"))
Eval (ConcatMapSymbol Isymb2aa ('Text "imu ih")) :: Text = 'Text "aamu aah"
Instances
type Eval (ConcatMapSymbol f ('Text sym) :: Text -> Type) Source # | |
Defined in Fcf.Data.NewText type Eval (ConcatMapSymbol f ('Text sym) :: Text -> Type) = Eval (Concat =<< (FMap f =<< (FMap CharToSymbol =<< ToCharList sym))) |
data ConcatMapCS :: (Char -> Exp Symbol) -> Text -> Exp Text Source #
ConcatMap for type-level text. This takes Char to Symbol function.
Instances
type Eval (ConcatMapCS f ('Text sym) :: Text -> Type) Source # | |
Defined in Fcf.Data.NewText type Eval (ConcatMapCS f ('Text sym) :: Text -> Type) = Eval (FromSymbol =<< (Concat =<< (FMap f =<< ToCharList sym))) |
data Any :: (Char -> Exp Bool) -> Text -> Exp Bool Source #
Any for type-level text. This takes Char to Bool function.
Example
>>>
:kind! Eval (Any IsDigit ('Text "aamu1"))
Eval (Any IsDigit ('Text "aamu1")) :: Bool = 'True
>>>
:kind! Eval (Any IsDigit ('Text "aamu"))
Eval (Any IsDigit ('Text "aamu")) :: Bool = 'False
data AnySymbol :: (Symbol -> Exp Bool) -> Text -> Exp Bool Source #
AnySymbol for type-level text. This takes Symbol to Bool function. Note that the given function needs to be compatible... (i.e. operating with symbols of length 1.
Example
>>>
:kind! Eval (AnySymbol Sym.IsDigit ('Text "aamu1"))
Eval (AnySymbol Sym.IsDigit ('Text "aamu1")) :: Bool = 'True
>>>
:kind! Eval (AnySymbol Sym.IsDigit ('Text "aamu"))
Eval (AnySymbol Sym.IsDigit ('Text "aamu")) :: Bool = 'False
data All :: (Char -> Exp Bool) -> Text -> Exp Bool Source #
All for type-level text. This takes Char to Bool function.
Example
>>>
:kind! Eval (All IsDigit ('Text "aamu1"))
Eval (All IsDigit ('Text "aamu1")) :: Bool = 'False
>>>
:kind! Eval (All IsDigit ('Text "321"))
Eval (All IsDigit ('Text "321")) :: Bool = 'True
data AllSymbol :: (Symbol -> Exp Bool) -> Text -> Exp Bool Source #
AllSymbol for type-level text. This takes Symbol to Bool function.
Example
>>>
:kind! Eval (AllSymbol Sym.IsDigit ('Text "aamu1"))
Eval (AllSymbol Sym.IsDigit ('Text "aamu1")) :: Bool = 'False
>>>
:kind! Eval (AllSymbol Sym.IsDigit ('Text "321"))
Eval (AllSymbol Sym.IsDigit ('Text "321")) :: Bool = 'True
Substrings
data Take :: Nat -> Text -> Exp Text Source #
Take for type-level text.
Example
>>>
:kind! Eval (Take 4 ('Text "aamun"))
Eval (Take 4 ('Text "aamun")) :: Text = 'Text "aamu"
data TakeEnd :: Nat -> Text -> Exp Text Source #
TakeEnd for type-level text.
Example
>>>
:kind! Eval (TakeEnd 4 ('Text "haamu"))
Eval (TakeEnd 4 ('Text "haamu")) :: Text = 'Text "aamu"
data Drop :: Nat -> Text -> Exp Text Source #
Drop for type-level text.
Example
>>>
:kind! Eval (Drop 2 ('Text "aamuna"))
Eval (Drop 2 ('Text "aamuna")) :: Text = 'Text "muna"
data DropEnd :: Nat -> Text -> Exp Text Source #
DropEnd for type-level text.
Example
>>>
:kind! Eval (DropEnd 2 ('Text "aamuna"))
Eval (DropEnd 2 ('Text "aamuna")) :: Text = 'Text "aamu"
data TakeWhile :: (Char -> Exp Bool) -> Text -> Exp Text Source #
TakeWhile for type-level text. This takes Char to Bool function.
Example
>>>
:kind! Eval (TakeWhile (Not <=< IsDigit) ('Text "aamu12"))
Eval (TakeWhile (Not <=< IsDigit) ('Text "aamu12")) :: Text = 'Text "aamu"
data TakeWhileSymbol :: (Symbol -> Exp Bool) -> Text -> Exp Text Source #
TakeWhileSymbol for type-level text. This takes Symbol to Bool function.
Example
>>>
:kind! Eval (TakeWhileSymbol (Not <=< Sym.IsDigit) ('Text "aamu12"))
Eval (TakeWhileSymbol (Not <=< Sym.IsDigit) ('Text "aamu12")) :: Text = 'Text "aamu"
Instances
type Eval (TakeWhileSymbol f txt :: Text -> Type) Source # | |
Defined in Fcf.Data.NewText type Eval (TakeWhileSymbol f txt :: Text -> Type) = Eval (FromSymbolList =<< (TakeWhile f =<< ToSymbolList txt)) |
data TakeWhileEnd :: (Char -> Exp Bool) -> Text -> Exp Text Source #
TakeWhileEnd for type-level text. This takes Char to Bool function.
Example
>>>
:kind! Eval (TakeWhileEnd (Not <=< IsDigit) ('Text "12aamu"))
Eval (TakeWhileEnd (Not <=< IsDigit) ('Text "12aamu")) :: Text = 'Text "aamu"
Instances
type Eval (TakeWhileEnd f ('Text sym) :: Text -> Type) Source # | |
Defined in Fcf.Data.NewText |
data TakeWhileEndSymbol :: (Symbol -> Exp Bool) -> Text -> Exp Text Source #
TakeWhileEndSymbol for type-level text. This takes Symbol to Bool function.
Example
>>>
:kind! Eval (TakeWhileEndSymbol (Not <=< Sym.IsDigit) ('Text "12aamu"))
Eval (TakeWhileEndSymbol (Not <=< Sym.IsDigit) ('Text "12aamu")) :: Text = 'Text "aamu"
data DropWhile :: (Char -> Exp Bool) -> Text -> Exp Text Source #
DropWhile for type-level text. This takes Char to Bool function.
Example
>>>
:kind! Eval (DropWhile IsDigit ('Text "12aamu"))
Eval (DropWhile IsDigit ('Text "12aamu")) :: Text = 'Text "aamu"
data DropWhileEnd :: (Char -> Exp Bool) -> Text -> Exp Text Source #
DropWhileEnd for type-level text.
Example
>>>
:kind! Eval (DropWhileEnd IsDigit ('Text "aamu12"))
Eval (DropWhileEnd IsDigit ('Text "aamu12")) :: Text = 'Text "aamu"
Instances
type Eval (DropWhileEnd f ('Text sym) :: Text -> Type) Source # | |
Defined in Fcf.Data.NewText |
data DropWhileEndSymbol :: (Symbol -> Exp Bool) -> Text -> Exp Text Source #
DropWhileEndSymbol for type-level text.
Example
>>>
:kind! Eval (DropWhileEndSymbol Sym.IsDigit ('Text "aamu12"))
Eval (DropWhileEndSymbol Sym.IsDigit ('Text "aamu12")) :: Text = 'Text "aamu"
data DropAround :: (Char -> Exp Bool) -> Text -> Exp Text Source #
DropAround for type-level text. This takes Char to Bool function.
Example
>>>
:kind! Eval (DropAround IsDigit ('Text "34aamu12"))
Eval (DropAround IsDigit ('Text "34aamu12")) :: Text = 'Text "aamu"
Instances
type Eval (DropAround f txt :: Text -> Type) Source # | |
Defined in Fcf.Data.NewText |
data DropAroundSymbol :: (Symbol -> Exp Bool) -> Text -> Exp Text Source #
DropAroundSymbol for type-level text. This takes Symbol to Bool function.
Example
>>>
:kind! Eval (DropAroundSymbol Sym.IsDigit ('Text "34aamu12"))
Eval (DropAroundSymbol Sym.IsDigit ('Text "34aamu12")) :: Text = 'Text "aamu"
Instances
type Eval (DropAroundSymbol f txt :: Text -> Type) Source # | |
Defined in Fcf.Data.NewText |
data Strip :: Text -> Exp Text Source #
Strip the space, newline and tab -symbols from the beginning and and of type-level text.
Example
>>>
:kind! Eval (Strip ('Text " aamu \n"))
Eval (Strip ('Text " aamu \n")) :: Text = 'Text "aamu"
Breaking etc
data SplitOn :: Text -> Text -> Exp [Text] Source #
SplitOn for type-level text.
Example
>>>
:kind! Eval (SplitOn ('Text "ab") ('Text "cdabfgabh"))
Eval (SplitOn ('Text "ab") ('Text "cdabfgabh")) :: [Text] = '[ 'Text "cd", 'Text "fg", 'Text "h"]
data Split :: (Char -> Exp Bool) -> Text -> Exp [Text] Source #
Split for type-level text. This takes Char to Bool function.
Example
>>>
:kind! Eval (Split C.IsSpace (Eval (FromSymbol "cd bf abh")))
Eval (Split C.IsSpace (Eval (FromSymbol "cd bf abh"))) :: [Text] = '[ 'Text "cd", 'Text "bf", 'Text "abh"]
data Lines :: Text -> Exp [Text] Source #
Lines for type-level text.
Example
>>>
:kind! Eval (Lines =<< FromSymbol "ok\nhmm\nab")
Eval (Lines =<< FromSymbol "ok\nhmm\nab") :: [Text] = '[ 'Text "ok", 'Text "hmm", 'Text "ab"]
data Words :: Text -> Exp [Text] Source #
Words for type-level text.
Example
>>>
:kind! Eval (Words =<< FromSymbol "ok hmm\nab")
Eval (Words =<< FromSymbol "ok hmm\nab") :: [Text] = '[ 'Text "ok", 'Text "hmm", 'Text "ab"]
data Unlines :: [Text] -> Exp Text Source #
Unlines for type-level text. This adds a newline to each Text and then concats them.
Example
>>>
:kind! Eval (Unlines '[ 'Text "ok", 'Text "hmm", 'Text "ab"])
Eval (Unlines '[ 'Text "ok", 'Text "hmm", 'Text "ab"]) :: Text = 'Text "ok\nhmm\nab\n"
data Unwords :: [Text] -> Exp Text Source #
Unwords for type-level text. This uses Intercalate
to add space-symbol
between the given texts.
Example
>>>
:kind! Eval (Unwords '[ 'Text "ok", 'Text "hmm", 'Text "ab"])
Eval (Unwords '[ 'Text "ok", 'Text "hmm", 'Text "ab"]) :: Text = 'Text "ok hmm ab"
Predicates
data IsPrefixOf :: Text -> Text -> Exp Bool Source #
IsPrefixOf for type-level text.
Example
>>>
:kind! Eval (IsPrefixOf ('Text "aa") ('Text "aamiainen"))
Eval (IsPrefixOf ('Text "aa") ('Text "aamiainen")) :: Bool = 'True
Instances
type Eval (IsPrefixOf l1 l2 :: Bool -> Type) Source # | |
Defined in Fcf.Data.NewText type Eval (IsPrefixOf l1 l2 :: Bool -> Type) = Eval (IsPrefixOf (Eval (ToList l1)) (Eval (ToList l2))) |
data IsSuffixOf :: Text -> Text -> Exp Bool Source #
IsSuffixOf for type-level text.
Example
>>>
:kind! Eval (IsSuffixOf ('Text "nen") ('Text "aamiainen"))
Eval (IsSuffixOf ('Text "nen") ('Text "aamiainen")) :: Bool = 'True
Instances
type Eval (IsSuffixOf l1 l2 :: Bool -> Type) Source # | |
Defined in Fcf.Data.NewText type Eval (IsSuffixOf l1 l2 :: Bool -> Type) = Eval (IsSuffixOf (Eval (ToList l1)) (Eval (ToList l2))) |