Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
utf8-string
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
utf8-string
Commits
555df32c
Commit
555df32c
authored
9 years ago
by
glguy
Browse files
Options
Downloads
Patches
Plain Diff
Eliminate some shadowing
parent
c7685d7b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Data/ByteString/Lazy/UTF8.hs
+6
-6
6 additions, 6 deletions
Data/ByteString/Lazy/UTF8.hs
with
6 additions
and
6 deletions
Data/ByteString/Lazy/UTF8.hs
+
6
−
6
View file @
555df32c
...
@@ -56,17 +56,17 @@ import Codec.Binary.UTF8.Generic (buncons)
...
@@ -56,17 +56,17 @@ import Codec.Binary.UTF8.Generic (buncons)
-- | Converts a Haskell string into a UTF8 encoded bytestring.
-- | Converts a Haskell string into a UTF8 encoded bytestring.
fromString
::
String
->
B
.
ByteString
fromString
::
String
->
B
.
ByteString
fromString
[]
=
B
.
empty
fromString
[]
=
B
.
empty
fromString
xs
=
packChunks
32
xs
fromString
xs
0
=
packChunks
32
xs
0
where
where
packChunks
n
xs
=
case
packUptoLenBytes
n
xs
of
packChunks
n
xs
=
case
packUptoLenBytes
n
xs
of
(
bs
,
[]
)
->
B
.
chunk
bs
B
.
Empty
(
bs
,
[]
)
->
B
.
chunk
bs
B
.
Empty
(
bs
,
xs
)
->
B
.
Chunk
bs
(
packChunks
(
min
(
n
*
2
)
B
.
smallChunkSize
)
xs
)
(
bs
,
xs
'
)
->
B
.
Chunk
bs
(
packChunks
(
min
(
n
*
2
)
B
.
smallChunkSize
)
xs
'
)
packUptoLenBytes
::
Int
->
String
->
(
S
.
ByteString
,
String
)
packUptoLenBytes
::
Int
->
String
->
(
S
.
ByteString
,
String
)
packUptoLenBytes
len
xs
=
unsafeCreateUptoN'
len
$
\
ptr
->
do
packUptoLenBytes
len
xs
=
unsafeCreateUptoN'
len
$
\
ptr
->
do
(
end
,
xs
)
<-
go
ptr
(
ptr
`
plusPtr
`
(
len
-
4
))
xs
(
end
,
xs
'
)
<-
go
ptr
(
ptr
`
plusPtr
`
(
len
-
4
))
xs
return
(
end
`
minusPtr
`
ptr
,
xs
)
return
(
end
`
minusPtr
`
ptr
,
xs
'
)
-- end is the last position at which you can write a whole 4 byte sequence safely
-- end is the last position at which you can write a whole 4 byte sequence safely
go
::
Ptr
Word8
->
Ptr
Word8
->
String
->
IO
(
Ptr
Word8
,
String
)
go
::
Ptr
Word8
->
Ptr
Word8
->
String
->
IO
(
Ptr
Word8
,
String
)
...
...
This diff is collapsed.
Click to expand it.
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