Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
text
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
text
Commits
1b275ff7
Unverified
Commit
1b275ff7
authored
4 years ago
by
Oleg Grenrus
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #308 from phadej/pr-306-span-break-doctest
Add examples to 'span' and 'break'
parents
dce58c13
c1d610b5
No related branches found
Branches containing commit
Tags
1.2.4.1
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Data/Text.hs
+6
-0
6 additions, 0 deletions
src/Data/Text.hs
src/Data/Text/Lazy.hs
+11
-0
11 additions, 0 deletions
src/Data/Text/Lazy.hs
with
17 additions
and
0 deletions
src/Data/Text.hs
+
6
−
0
View file @
1b275ff7
...
...
@@ -1359,6 +1359,9 @@ splitAt n t@(Text arr off len)
-- a pair whose first element is the longest prefix (possibly empty)
-- of @t@ of elements that satisfy @p@, and whose second is the
-- remainder of the list.
--
-- >>> T.span (=='0') "000AB"
-- ("000","AB")
span
::
(
Char
->
Bool
)
->
Text
->
(
Text
,
Text
)
span
p
t
=
case
span_
p
t
of
(
#
hd
,
tl
#
)
->
(
hd
,
tl
)
...
...
@@ -1366,6 +1369,9 @@ span p t = case span_ p t of
-- | /O(n)/ 'break' is like 'span', but the prefix returned is
-- over elements that fail the predicate @p@.
--
-- >>> T.break (=='c') "180cm"
-- ("180","cm")
break
::
(
Char
->
Bool
)
->
Text
->
(
Text
,
Text
)
break
p
=
span
(
not
.
p
)
{-# INLINE break #-}
...
...
This diff is collapsed.
Click to expand it.
src/Data/Text/Lazy.hs
+
11
−
0
View file @
1b275ff7
...
...
@@ -307,6 +307,11 @@ import Text.Printf (PrintfArg, formatArg, formatString)
-- measure. For details, see
-- <http://unicode.org/reports/tr36/#Deletion_of_Noncharacters Unicode Technical Report 36, §3.5 >.)
-- $setup
-- >>> import Data.Text
-- >>> import qualified Data.Text as T
-- >>> :seti -XOverloadedStrings
equal
::
Text
->
Text
->
Bool
equal
Empty
Empty
=
True
equal
Empty
_
=
False
...
...
@@ -1385,6 +1390,9 @@ breakOnAll pat src
-- | /O(n)/ 'break' is like 'span', but the prefix returned is over
-- elements that fail the predicate @p@.
--
-- >>> T.break (=='c') "180cm"
-- ("180","cm")
break
::
(
Char
->
Bool
)
->
Text
->
(
Text
,
Text
)
break
p
t0
=
break'
t0
where
break'
Empty
=
(
empty
,
empty
)
...
...
@@ -1400,6 +1408,9 @@ break p t0 = break' t0
-- a pair whose first element is the longest prefix (possibly empty)
-- of @t@ of elements that satisfy @p@, and whose second is the
-- remainder of the list.
--
-- >>> T.span (=='0') "000AB"
-- ("000","AB")
span
::
(
Char
->
Bool
)
->
Text
->
(
Text
,
Text
)
span
p
=
break
(
not
.
p
)
{-# INLINE span #-}
...
...
This diff is collapsed.
Click to expand it.
Ben Gamari
@bgamari
mentioned in commit
0998ad09
·
3 years ago
mentioned in commit
0998ad09
mentioned in commit 0998ad09e8ef566a5d6f2a69144b212ad3107bd6
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment