text1-0.0.3: Non-empty values of `Data.Text`.

Safe HaskellNone
LanguageHaskell2010

Data.Text1

Synopsis

Documentation

length1 :: Text1 -> Int Source

>>> fmap length1 ("a" ^? _Text1)
Just 1
>>> fmap length1 ("abc" ^? _Text1)
Just 3
length1 t >= 1

compareLength1 :: Text1 -> Int -> Ordering Source

>>> fmap (`compareLength1` 1) ("a" ^? _Text1)
Just EQ
>>> fmap (`compareLength1` 3) ("a" ^? _Text1)
Just LT
>>> fmap (`compareLength1` 1) ("abc" ^? _Text1)
Just GT
>>> fmap (`compareLength1` 3) ("abc" ^? _Text1)
Just EQ
>>> fmap (`compareLength1` 5) ("abc" ^? _Text1)
Just LT
compareLength1 t 1 /= LT

_head1 :: Lens' Text1 Char Source

>>> fmap (^. _head1) ("a" ^? _Text1)
Just 'a'
>>> fmap (^. _head1) ("abc" ^? _Text1)
Just 'a'
>>> fmap (_head1 %~ toUpper) ("abc" ^? _Text1)
Just "Abc"

_tail1 :: Lens' Text1 Text Source

>>> fmap (^. _tail1) ("a" ^? _Text1)
Just ""
>>> fmap (^. _tail1) ("abc" ^? _Text1)
Just "bc"
>>> fmap (_tail1 %~ Text.toUpper) ("abc" ^? _Text1)
Just "aBC"

_last1 :: Lens' Text1 Char Source

>>> fmap (^. _last1) ("a" ^? _Text1)
Just 'a'
>>> fmap (^. _last1) ("abc" ^? _Text1)
Just 'c'
>>> fmap (_last1 %~ toUpper) ("abc" ^? _Text1)
Just "abC"

_init1 :: Lens' Text1 Text Source

>>> fmap (^. _init1) ("a" ^? _Text1)
Just ""
>>> fmap (^. _init1) ("abc" ^? _Text1)
Just "ab"
>>> fmap (_init1 %~ Text.toUpper) ("a" ^? _Text1)
Just "a"
>>> fmap (_init1 %~ Text.toUpper) ("abc" ^? _Text1)
Just "ABc"

class AsText1 p f s where Source

Minimal complete definition

Nothing

Methods

_Text1 :: Optic' p f s Text1 Source

class AsSingle c a | c -> a where Source

Minimal complete definition

Nothing

Methods

_Single :: Prism' c a Source

class OneAnd s t a b x y | s -> a, s -> x, t -> b, t -> y, s b -> t, x b -> t, t a -> s, y a -> s where Source

Minimal complete definition

Nothing

Methods

_OneAnd :: Iso s t (a, x) (b, y) Source