Data.String.NonEmpty
Re-exports from Data.String.NonEmpty.CodePoints
#uncons
uncons :: NonEmptyString -> { head :: CodePoint, tail :: Maybe NonEmptyString }#toNonEmptyCodePointArray
#toCodePointArray
#takeWhile
takeWhile :: (CodePoint -> Boolean) -> NonEmptyString -> Maybe NonEmptyString#take
take :: Int -> NonEmptyString -> Maybe NonEmptyString#splitAt
splitAt :: Int -> NonEmptyString -> { after :: Maybe NonEmptyString, before :: Maybe NonEmptyString }#snoc
snoc :: CodePoint -> String -> NonEmptyString#singleton
singleton :: CodePoint -> NonEmptyString#length
length :: NonEmptyString -> Int#lastIndexOf'
lastIndexOf' :: Pattern -> Int -> NonEmptyString -> Maybe Int#lastIndexOf
lastIndexOf :: Pattern -> NonEmptyString -> Maybe Int#fromNonEmptyCodePointArray
#fromFoldable1
fromFoldable1 :: forall f. Foldable1 f => f CodePoint -> NonEmptyString#fromCodePointArray
#dropWhile
dropWhile :: (CodePoint -> Boolean) -> NonEmptyString -> Maybe NonEmptyString#drop
drop :: Int -> NonEmptyString -> Maybe NonEmptyString#countPrefix
countPrefix :: (CodePoint -> Boolean) -> NonEmptyString -> Int#cons
cons :: CodePoint -> String -> NonEmptyString#codePointAt
codePointAt :: Int -> NonEmptyString -> Maybe CodePointRe-exports from Data.String.NonEmpty.Internal
#NonEmptyString
#NonEmptyReplacement
newtype NonEmptyReplacementA newtype used in cases to specify a non-empty replacement for a pattern.
Constructors
Instances
#MakeNonEmpty
class MakeNonEmpty (s :: Symbol) whereA helper class for defining non-empty string values at compile time.
something :: NonEmptyString
something = nes (SProxy :: SProxy "something")
Members
nes :: SProxy s -> NonEmptyString
Instances
(Fail (Text "Cannot create an NonEmptyString from an empty Symbol")) => MakeNonEmpty ""(IsSymbol s) => MakeNonEmpty s
#unsafeFromString
unsafeFromString :: Partial => String -> NonEmptyStringA partial version of fromString.
#trim
trim :: NonEmptyString -> Maybe NonEmptyStringRemoves whitespace from the beginning and end of a string, including whitespace characters and line terminators. If the string is entirely made up of whitespace the result will be Nothing.
trim (NonEmptyString " Hello \n World\n\t ") == Just (NonEmptyString "Hello \n World")
trim (NonEmptyString " \n") == Nothing
#toUpper
toUpper :: NonEmptyString -> NonEmptyStringReturns the argument converted to uppercase.
toUpper (NonEmptyString "Hello") == NonEmptyString "HELLO"
#toString
toString :: NonEmptyString -> StringConverts a NonEmptyString back into a standard String.
#toLower
toLower :: NonEmptyString -> NonEmptyStringReturns the argument converted to lowercase.
toLower (NonEmptyString "hElLo") == NonEmptyString "hello"
#stripSuffix
stripSuffix :: Pattern -> NonEmptyString -> Maybe NonEmptyStringIf the string ends with the given suffix, return the portion of the
string left after removing it. If the suffix does not match or there is no
remainder, the result will be Nothing.
stripSuffix (Pattern ".exe") (NonEmptyString "purs.exe") == Just (NonEmptyString "purs")
stripSuffix (Pattern ".exe") (NonEmptyString "purs") == Nothing
stripSuffix (Pattern "Hello!") (NonEmptyString "Hello!") == Nothing
#stripPrefix
stripPrefix :: Pattern -> NonEmptyString -> Maybe NonEmptyStringIf the string starts with the given prefix, return the portion of the
string left after removing it. If the prefix does not match or there is no
remainder, the result will be Nothing.
stripPrefix (Pattern "http:") (NonEmptyString "http://purescript.org") == Just (NonEmptyString "//purescript.org")
stripPrefix (Pattern "http:") (NonEmptyString "https://purescript.org") == Nothing
stripPrefix (Pattern "Hello!") (NonEmptyString "Hello!") == Nothing
#replaceAll
replaceAll :: Pattern -> NonEmptyReplacement -> NonEmptyString -> NonEmptyStringReplaces all occurences of the pattern with the replacement string.
replaceAll (Pattern "<=") (NonEmptyReplacement "≤") (NonEmptyString "a <= b <= c") == NonEmptyString "a ≤ b ≤ c"
#replace
replace :: Pattern -> NonEmptyReplacement -> NonEmptyString -> NonEmptyStringReplaces the first occurence of the pattern with the replacement string.
replace (Pattern "<=") (NonEmptyReplacement "≤") (NonEmptyString "a <= b <= c") == NonEmptyString "a ≤ b <= c"
#prependString
prependString :: String -> NonEmptyString -> NonEmptyStringPrepends a string to this non-empty string. Since one of the strings is non-empty we know the result will be too.
prependString "be" (NonEmptyString "fore") == NonEmptyString "before"
prependString "" (NonEmptyString "fore") == NonEmptyString "fore"
#localeCompare
localeCompare :: NonEmptyString -> NonEmptyString -> OrderingCompare two strings in a locale-aware fashion. This is in contrast to
the Ord instance on String which treats strings as arrays of code
units:
NonEmptyString "ä" `localeCompare` NonEmptyString "b" == LT
NonEmptyString "ä" `compare` NonEmptyString "b" == GT
#joinWith1
joinWith1 :: forall f. Foldable1 f => NonEmptyString -> f String -> NonEmptyStringJoins possibly empty strings in a non-empty container together as a new non-empty string, inserting a non-empty string as a separator between them. The result is guaranteed to be non-empty.
-- array syntax is used for demonstration here, it would need to be a real `Foldable1`
joinWith1 (NonEmptyString ", ") ["apple", "banana"] == NonEmptyString "apple, banana"
joinWith1 (NonEmptyString "/") ["a", "b", "", "c", ""] == NonEmptyString "a/b//c/"
#joinWith
joinWith :: forall f. Foldable f => String -> f NonEmptyString -> StringJoins the strings in a container together as a new string, inserting the first argument as separator between them. The result is not guaranteed to be non-empty.
joinWith ", " [NonEmptyString "apple", NonEmptyString "banana"] == "apple, banana"
joinWith ", " [] == ""
#join1With
join1With :: forall f. Foldable1 f => String -> f NonEmptyString -> NonEmptyStringJoins non-empty strings in a non-empty container together as a new non-empty string, inserting a possibly empty string as separator between them. The result is guaranteed to be non-empty.
-- array syntax is used for demonstration here, it would need to be a real `Foldable1`
join1With ", " [NonEmptyString "apple", NonEmptyString "banana"] == NonEmptyString "apple, banana"
join1With "" [NonEmptyString "apple", NonEmptyString "banana"] == NonEmptyString "applebanana"
#fromString
fromString :: String -> Maybe NonEmptyStringCreates a NonEmptyString from a String, returning Nothing if the
input is empty.
fromString "" = Nothing
fromString "hello" = Just (NES.unsafeFromString "hello")
#contains
contains :: Pattern -> NonEmptyString -> BooleanChecks whether the pattern appears in the given string.
contains (Pattern "needle") (NonEmptyString "haystack with needle") == true
contains (Pattern "needle") (NonEmptyString "haystack") == false
#appendString
appendString :: NonEmptyString -> String -> NonEmptyStringAppends a string to this non-empty string. Since one of the strings is non-empty we know the result will be too.
appendString (NonEmptyString "Hello") " world" == NonEmptyString "Hello world"
appendString (NonEmptyString "Hello") "" == NonEmptyString "Hello"
Re-exports from Data.String.Pattern
Modules
- Control.Alt
- Control.Alternative
- Control.Applicative
- Control.Apply
- Control.Biapplicative
- Control.Biapply
- Control.Bind
- Control.Category
- Control.Comonad
- Control.Extend
- Control.Lazy
- Control.Monad
- Control.Monad.Gen
- Control.Monad.Gen.Class
- Control.Monad.Gen.Common
- Control.Monad.Rec.Class
- Control.Monad.ST
- Control.Monad.ST.Class
- Control.Monad.ST.Global
- Control.Monad.ST.Internal
- Control.Monad.ST.Ref
- Control.MonadPlus
- Control.MonadZero
- Control.Plus
- Control.Semigroupoid
- Data.Array
- Data.Array.NonEmpty
- Data.Array.NonEmpty.Internal
- Data.Array.Partial
- Data.Array.ST
- Data.Array.ST.Iterator
- Data.Array.ST.Partial
- Data.Bifoldable
- Data.Bifunctor
- Data.Bifunctor.Clown
- Data.Bifunctor.Flip
- Data.Bifunctor.Join
- Data.Bifunctor.Joker
- Data.Bifunctor.Product
- Data.Bifunctor.Wrap
- Data.Bitraversable
- Data.Boolean
- Data.BooleanAlgebra
- Data.Bounded
- Data.Char
- Data.Char.Gen
- Data.Char.Utils
- Data.CommutativeRing
- Data.Distributive
- Data.DivisionRing
- Data.Either
- Data.Either.Inject
- Data.Either.Nested
- Data.Enum
- Data.Enum.Gen
- Data.Eq
- Data.EuclideanRing
- Data.Field
- Data.Foldable
- Data.FoldableWithIndex
- Data.Function
- Data.Function.Uncurried
- Data.Functor
- Data.Functor.Invariant
- Data.FunctorWithIndex
- Data.HeytingAlgebra
- Data.Identity
- Data.Int
- Data.Int.Bits
- Data.Maybe
- Data.Maybe.First
- Data.Maybe.Last
- Data.Monoid
- Data.Monoid.Additive
- Data.Monoid.Alternate
- Data.Monoid.Conj
- Data.Monoid.Disj
- Data.Monoid.Dual
- Data.Monoid.Endo
- Data.Monoid.Multiplicative
- Data.NaturalTransformation
- Data.Newtype
- Data.NonEmpty
- Data.Ord
- Data.Ord.Down
- Data.Ord.Max
- Data.Ord.Min
- Data.Ord.Unsafe
- Data.Ordering
- Data.Ring
- Data.Semigroup
- Data.Semigroup.First
- Data.Semigroup.Foldable
- Data.Semigroup.Last
- Data.Semigroup.Traversable
- Data.Semiring
- Data.Show
- Data.String
- Data.String.CaseInsensitive
- Data.String.CodePoints
- Data.String.CodeUnits
- Data.String.Common
- Data.String.Gen
- Data.String.NonEmpty
- Data.String.NonEmpty.CaseInsensitive
- Data.String.NonEmpty.CodePoints
- Data.String.NonEmpty.CodeUnits
- Data.String.NonEmpty.Internal
- Data.String.Pattern
- Data.String.Regex
- Data.String.Regex.Flags
- Data.String.Regex.Unsafe
- Data.String.Unsafe
- Data.String.Utils
- Data.Symbol
- Data.Traversable
- Data.Traversable.Accum
- Data.Traversable.Accum.Internal
- Data.TraversableWithIndex
- Data.Tuple
- Data.Tuple.Nested
- Data.Unfoldable
- Data.Unfoldable1
- Data.Unit
- Data.Void
- Effect
- Effect.Class
- Effect.Class.Console
- Effect.Console
- Effect.Ref
- Effect.Uncurried
- Effect.Unsafe
- Global
- Global.Unsafe
- MCPrelude
- Main
- Math
- PSCI.Support
- Partial
- Partial.Unsafe
- Prelude
- Prim
- Prim.Boolean
- Prim.Ordering
- Prim.Row
- Prim.RowList
- Prim.Symbol
- Prim.TypeError
- Record.Unsafe
- Type.Data.Row
- Type.Data.RowList
- Type.Equality
- Unsafe.Coerce