Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data NonEmptyText (n :: Nat)
- type (<=) (x :: k) (y :: k) = (x <=? y) ~ 'True
- mkNonEmptyText :: forall n. KnownNat n => Text -> Maybe (NonEmptyText n)
- unsafeMkNonEmptyText :: forall n. KnownNat n => Text -> NonEmptyText n
- nonEmptyTextToText :: NonEmptyText n -> Text
- compileNonEmptyText :: Integer -> QuasiQuoter
- compileNonEmptyTextKnownLength :: QuasiQuoter
- convertEmptyTextToNothing :: Text -> Maybe Text
- widen :: (1 <= n, n <= m) => NonEmptyText n -> NonEmptyText m
- takeNonEmptyText :: forall m n. (KnownNat m, KnownNat n, n <= m) => NonEmptyText m -> NonEmptyText n
- takeNonEmptyTextEnd :: forall m n. (KnownNat m, KnownNat n, n <= m) => NonEmptyText m -> NonEmptyText n
- chunksOfNonEmptyText :: forall chunkSize totalSize. (KnownNat chunkSize, KnownNat totalSize) => NonEmptyText totalSize -> [NonEmptyText chunkSize]
- filterNonEmptyText :: (Char -> Bool) -> NonEmptyText n -> NonEmptyText n
- (<>|) :: NonEmptyText n -> NonEmptyText m -> NonEmptyText (n + m)
- data ContainsNonWhitespaceCharacters = ContainsNonWhitespaceCharacters
- exactLengthRefinedToRange :: Refined (ContainsNonWhitespaceCharacters && SizeEqualTo n) Text -> NonEmptyText n
- nonEmptyTextFromRefined :: Refined (ContainsNonWhitespaceCharacters && (SizeLessThan n || SizeEqualTo n)) Text -> NonEmptyText n
- refinedFromNonEmptyText :: NonEmptyText n -> Refined (ContainsNonWhitespaceCharacters && (SizeLessThan n || SizeEqualTo n)) Text
- useNat :: Integer -> (forall n proxy. KnownNat n => proxy n -> x) -> x
- natOfLength :: proxy (n :: Nat) -> f (other n) -> f (other n)
Non empty text
data NonEmptyText (n :: Nat) Source #
Non Empty Text, requires the input is between 1 and n
chars and not just whitespace.
Instances
type (<=) (x :: k) (y :: k) = (x <=? y) ~ 'True infix 4 #
Comparison (<=) of comparable types, as a constraint.
Since: base-4.16.0.0
Construction
mkNonEmptyText :: forall n. KnownNat n => Text -> Maybe (NonEmptyText n) Source #
unsafeMkNonEmptyText :: forall n. KnownNat n => Text -> NonEmptyText n Source #
Make a NonEmptyText when you can manually verify the length
nonEmptyTextToText :: NonEmptyText n -> Text Source #
Conversion
widen :: (1 <= n, n <= m) => NonEmptyText n -> NonEmptyText m Source #
Converts a NonEmptyText
to a wider NonEmptyText
Functions
takeNonEmptyText :: forall m n. (KnownNat m, KnownNat n, n <= m) => NonEmptyText m -> NonEmptyText n Source #
Narrows the maximum length, dropping any remaining trailing characters.
takeNonEmptyTextEnd :: forall m n. (KnownNat m, KnownNat n, n <= m) => NonEmptyText m -> NonEmptyText n Source #
Narrows the maximum length, dropping any prefix remaining characters.
chunksOfNonEmptyText :: forall chunkSize totalSize. (KnownNat chunkSize, KnownNat totalSize) => NonEmptyText totalSize -> [NonEmptyText chunkSize] Source #
O(n) Splits a NonEmptyText
into components of length chunkSize
. The
last element may be shorter than the other chunks, depending on the length
of the input.
filterNonEmptyText :: (Char -> Bool) -> NonEmptyText n -> NonEmptyText n Source #
Identical to the normal text filter function, but maintains the type-level invariant that the text length is <= n, unlike unwrapping the text, filtering, then rewrapping the text.
(<>|) :: NonEmptyText n -> NonEmptyText m -> NonEmptyText (n + m) Source #
Concat two NonEmptyText values, with the new maximum length being the sum of the two maximum lengths of the inputs.
Mnemonic: <>
for monoid, |
from NonEmpty's :|
operator
Conversions between Refined
and NonEmptyText
.
data ContainsNonWhitespaceCharacters Source #
Instances
exactLengthRefinedToRange :: Refined (ContainsNonWhitespaceCharacters && SizeEqualTo n) Text -> NonEmptyText n Source #
nonEmptyTextFromRefined :: Refined (ContainsNonWhitespaceCharacters && (SizeLessThan n || SizeEqualTo n)) Text -> NonEmptyText n Source #
refinedFromNonEmptyText :: NonEmptyText n -> Refined (ContainsNonWhitespaceCharacters && (SizeLessThan n || SizeEqualTo n)) Text Source #
Convenience util if you need a NonEmptyText of a dynamically determined lengths
natOfLength :: proxy (n :: Nat) -> f (other n) -> f (other n) Source #