| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Shrun.Data.Text
Contents
Synopsis
- newtype UnlinedText = UnsafeUnlinedText {}
- fromText :: Text -> [UnlinedText]
- fromTextReplace :: Text -> UnlinedText
- unsafeFromTextNE :: HasCallStack => Text -> NonEmpty UnlinedText
- unsafeUnlinedText :: HasCallStack => Text -> UnlinedText
- toText :: [UnlinedText] -> Text
- length :: UnlinedText -> Int
- concat :: [UnlinedText] -> UnlinedText
- intercalate :: UnlinedText -> [UnlinedText] -> UnlinedText
- isWhitespace :: UnlinedText -> Bool
- reallyUnsafeMap :: (Text -> Text) -> UnlinedText -> UnlinedText
Documentation
newtype UnlinedText Source #
Text after it has had all lines separated into different texts. We introduce a newtype for clarity. The idea is that when we read arbitrary text from a handle, this type serves as a witness that we have indeed split the string along newlines. Then, in the normal case, we log each line separately.
In exceptional cases (e.g. command names), we may choose to combine the list back into a single text, according to some logic.
The constructor UnsafeUnlinedText should only be used when we know
the text has no newlines and performance means a branch is undesirable
(e.g. streaming). If there is no performance impact, consider
unsafeUnlinedText instead.
Constructors
| UnsafeUnlinedText | |
Fields | |
Instances
| Monoid UnlinedText Source # | |
Defined in Shrun.Data.Text Methods mempty :: UnlinedText # mappend :: UnlinedText -> UnlinedText -> UnlinedText # mconcat :: [UnlinedText] -> UnlinedText # | |
| Semigroup UnlinedText Source # | |
Defined in Shrun.Data.Text Methods (<>) :: UnlinedText -> UnlinedText -> UnlinedText # sconcat :: NonEmpty UnlinedText -> UnlinedText # stimes :: Integral b => b -> UnlinedText -> UnlinedText # | |
| IsString UnlinedText Source # | |
Defined in Shrun.Data.Text Methods fromString :: String -> UnlinedText # | |
| Show UnlinedText Source # | |
Defined in Shrun.Data.Text Methods showsPrec :: Int -> UnlinedText -> ShowS # show :: UnlinedText -> String # showList :: [UnlinedText] -> ShowS # | |
| Eq UnlinedText Source # | |
Defined in Shrun.Data.Text | |
| (k ~ A_Getter, a ~ Text, b ~ Text) => LabelOptic "unUnlinedText" k UnlinedText UnlinedText a b Source # | |
Defined in Shrun.Data.Text Methods labelOptic :: Optic k NoIx UnlinedText UnlinedText a b Source # | |
Creation
fromText :: Text -> [UnlinedText] Source #
Creates a list of UnlinedText.
fromTextReplace :: Text -> UnlinedText Source #
Creates a single UnlinedText by replacing newlines with
whitespace.
unsafeFromTextNE :: HasCallStack => Text -> NonEmpty UnlinedText Source #
Requires input text to be non-empty to be safe.
unsafeUnlinedText :: HasCallStack => Text -> UnlinedText Source #
Unsafe creation that throws error when the text contains newline(s).
Elimination
toText :: [UnlinedText] -> Text Source #
Functions
length :: UnlinedText -> Int Source #
concat :: [UnlinedText] -> UnlinedText Source #
Concats via toText.
intercalate :: UnlinedText -> [UnlinedText] -> UnlinedText Source #
isWhitespace :: UnlinedText -> Bool Source #
reallyUnsafeMap :: (Text -> Text) -> UnlinedText -> UnlinedText Source #
Lifts a Text function to UnlinedText. Very unsafe in that we do not
check for errors i.e. if the parameter function introduces any newlines,
then this will silently succeed. This exists for performance.