Skip to content

Commit cb76985

Browse files
committed
Tweak haddocks
1 parent 6458f06 commit cb76985

File tree

5 files changed

+48
-50
lines changed

5 files changed

+48
-50
lines changed

src/Data/Text/Builder/Linear.hs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- Licence: BSD3
44
-- Maintainer: Andrew Lelechenko <[email protected]>
55
--
6-
-- Builder for strict 'Text' and 'ByteString', based on linear types. It consistently
6+
-- Builder for strict t'Text' and 'ByteString', based on linear types. It consistently
77
-- outperforms "Data.Text.Lazy.Builder"
88
-- from @text@ as well as a strict builder from @text-builder@,
99
-- and scales better.
@@ -27,7 +27,7 @@ import GHC.Exts (Addr#, IsString (..))
2727

2828
import Data.Text.Builder.Linear.Buffer
2929

30-
-- | Thin wrapper over 'Buffer' with a handy 'Semigroup' instance.
30+
-- | Thin wrapper over t'Buffer' with a handy 'Semigroup' instance.
3131
--
3232
-- >>> :set -XOverloadedStrings -XMagicHash
3333
-- >>> fromText "foo" <> fromChar '_' <> fromAddr "bar"#
@@ -36,9 +36,9 @@ import Data.Text.Builder.Linear.Buffer
3636
-- Remember: this is a strict builder, so on contrary to "Data.Text.Lazy.Builder"
3737
-- for optimal performance you should use strict left folds instead of lazy right ones.
3838
--
39-
-- Note that (similar to other builders) concatenation of 'Builder's allocates
39+
-- Note that (similar to other builders) concatenation of t'Builder's allocates
4040
-- thunks. This is to a certain extent mitigated by aggressive inlining,
41-
-- but it is faster to use 'Buffer' directly.
41+
-- but it is faster to use t'Buffer' directly.
4242
newtype Builder = Builder {unBuilder Buffer Buffer}
4343

4444
-- | @since 0.1.4
@@ -53,7 +53,7 @@ instance Ord Builder where
5353
b1 >= b2 = runBuilder b1 >= runBuilder b2
5454
b1 > b2 = runBuilder b1 > runBuilder b2
5555

56-
-- | Run 'Builder' computation on an empty 'Buffer', returning strict 'Text'.
56+
-- | Run t'Builder' computation on an empty t'Buffer', returning strict t'Text'.
5757
--
5858
-- >>> :set -XOverloadedStrings -XMagicHash
5959
-- >>> runBuilder (fromText "foo" <> fromChar '_' <> fromAddr "bar"#)
@@ -81,12 +81,12 @@ instance Monoid Builder where
8181
mempty = Builder (\b b)
8282
{-# INLINE mempty #-}
8383

84-
-- | Use 'fromString' to create 'Builder' from 'String'.
84+
-- | Use 'fromString' to create t'Builder' from 'String'.
8585
instance IsString Builder where
8686
fromString = fromText . fromString
8787
{-# INLINE fromString #-}
8888

89-
-- | Create 'Builder', containing a given 'Text'.
89+
-- | Create t'Builder', containing a given t'Text'.
9090
--
9191
-- >>> :set -XOverloadedStrings
9292
-- >>> fromText "foo" <> fromText "bar"
@@ -97,7 +97,7 @@ fromText ∷ Text → Builder
9797
fromText x = Builder $ \b b |> x
9898
{-# INLINE fromText #-}
9999

100-
-- | Create 'Builder', containing a given 'Char'.
100+
-- | Create t'Builder', containing a given 'Char'.
101101
--
102102
-- >>> fromChar 'x' <> fromChar 'y'
103103
-- "xy"
@@ -108,7 +108,7 @@ fromChar ∷ Char → Builder
108108
fromChar x = Builder $ \b b |>. x
109109
{-# INLINE fromChar #-}
110110

111-
-- | Create 'Builder', containing a null-terminated UTF-8 string, specified by 'Addr#'.
111+
-- | Create t'Builder', containing a null-terminated UTF-8 string, specified by 'Addr#'.
112112
--
113113
-- >>> :set -XMagicHash
114114
-- >>> fromAddr "foo"# <> fromAddr "bar"#
@@ -120,15 +120,15 @@ fromAddr ∷ Addr# → Builder
120120
fromAddr x = Builder $ \b b |># x
121121
{-# INLINE fromAddr #-}
122122

123-
-- | Create 'Builder', containing decimal representation of a given /bounded/ integer.
123+
-- | Create t'Builder', containing decimal representation of a given /bounded/ integer.
124124
--
125125
-- >>> fromChar 'x' <> fromDec (123 :: Int)
126126
-- "x123"
127127
fromDec (Integral a, FiniteBits a) a Builder
128128
fromDec x = Builder $ \b b |>$ x
129129
{-# INLINE fromDec #-}
130130

131-
-- | Create 'Builder', containing decimal representation of a given /unbounded/ integer.
131+
-- | Create t'Builder', containing decimal representation of a given /unbounded/ integer.
132132
--
133133
-- >>> fromChar 'x' <> fromUnboundedDec (1e24 :: Integer)
134134
-- "x1000000000000000000000000"
@@ -138,7 +138,7 @@ fromUnboundedDec ∷ Integral a ⇒ a → Builder
138138
fromUnboundedDec x = Builder $ \b b |>$$ x
139139
{-# INLINE fromUnboundedDec #-}
140140

141-
-- | Create 'Builder', containing hexadecimal representation of a given integer.
141+
-- | Create t'Builder', containing hexadecimal representation of a given integer.
142142
--
143143
-- >>> :set -XMagicHash
144144
-- >>> fromAddr "0x"# <> fromHex (0x123def :: Int)
@@ -147,7 +147,7 @@ fromHex ∷ (Integral a, FiniteBits a) ⇒ a → Builder
147147
fromHex x = Builder $ \b b |>& x
148148
{-# INLINE fromHex #-}
149149

150-
-- | Create 'Builder', containing decimal representation of a given 'Double'.
150+
-- | Create t'Builder', containing decimal representation of a given 'Double'.
151151
--
152152
-- >>> :set -XMagicHash
153153
-- >>> fromAddr "pi="# <> fromDouble pi

src/Data/Text/Builder/Linear/Buffer.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Licence: BSD3
55
-- Maintainer: Andrew Lelechenko <[email protected]>
66
--
7-
-- 'Buffer' for strict 'Text', based on linear types.
7+
-- t'Buffer' for strict t'Text', based on linear types.
88
module Data.Text.Builder.Linear.Buffer (
99
-- * Type
1010
Buffer,
@@ -83,7 +83,7 @@ import Data.Text.Builder.Linear.Dec.Unbounded
8383
import Data.Text.Builder.Linear.Double
8484
import Data.Text.Builder.Linear.Hex
8585

86-
-- | Append 'Text' suffix to a 'Buffer' by mutating it.
86+
-- | Append t'Text' suffix to a t'Buffer' by mutating it.
8787
-- If a suffix is statically known, consider using '(|>#)' for optimal performance.
8888
--
8989
-- >>> :set -XOverloadedStrings -XLinearTypes
@@ -98,7 +98,7 @@ buffer |> (Text src srcOff srcLen) =
9898
(\dst dstOff A.copyI srcLen dst dstOff src srcOff)
9999
buffer
100100

101-
-- | Prepend 'Text' prefix to a 'Buffer' by mutating it.
101+
-- | Prepend t'Text' prefix to a t'Buffer' by mutating it.
102102
-- If a prefix is statically known, consider using '(#<|)' for optimal performance.
103103
--
104104
-- >>> :set -XOverloadedStrings -XLinearTypes
@@ -114,7 +114,7 @@ Text src srcOff srcLen <| buffer =
114114
buffer
115115

116116
-- | Append a null-terminated UTF-8 string
117-
-- to a 'Buffer' by mutating it. E. g.,
117+
-- to a t'Buffer' by mutating it. E. g.,
118118
--
119119
-- >>> :set -XOverloadedStrings -XLinearTypes -XMagicHash
120120
-- >>> runBuffer (\b -> b |># "foo"# |># "bar"#)
@@ -134,7 +134,7 @@ buffer |># addr# =
134134
srcLen = I# (cstringLength# addr#)
135135

136136
-- | Prepend a null-terminated UTF-8 string
137-
-- to a 'Buffer' by mutating it. E. g.,
137+
-- to a t'Buffer' by mutating it. E. g.,
138138
--
139139
-- >>> :set -XOverloadedStrings -XLinearTypes -XMagicHash
140140
-- >>> runBuffer (\b -> "foo"# #<| "bar"# #<| b)

src/Data/Text/Builder/Linear/Char.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import Data.Text.Builder.Linear.Core
3131
-- Single char
3232
--------------------------------------------------------------------------------
3333

34-
-- | Append 'Char' to a 'Buffer' by mutating it.
34+
-- | Append 'Char' to a t'Buffer' by mutating it.
3535
--
3636
-- >>> :set -XLinearTypes
3737
-- >>> runBuffer (\b -> b |>. 'q' |>. 'w')
@@ -45,7 +45,7 @@ import Data.Text.Builder.Linear.Core
4545
infixl 6 |>.
4646
buffer |>. ch = appendBounded 4 (\dst dstOff unsafeWrite dst dstOff ch) buffer
4747

48-
-- | Prepend 'Char' to a 'Buffer' by mutating it.
48+
-- | Prepend 'Char' to a t'Buffer' by mutating it.
4949
--
5050
-- >>> :set -XLinearTypes
5151
-- >>> runBuffer (\b -> 'q' .<| 'w' .<| b)
@@ -95,7 +95,7 @@ unsafePrependCharM marr off c = case utf8Length c of
9595
-- Multiple chars
9696
--------------------------------------------------------------------------------
9797

98-
-- | Prepend a given count of a 'Char' to a 'Buffer'.
98+
-- | Prepend a given count of a 'Char' to a t'Buffer'.
9999
--
100100
-- >>> :set -XLinearTypes
101101
-- >>> runBuffer (\b -> prependChars 3 'x' (b |>. 'A'))
@@ -115,7 +115,7 @@ prependChars count ch buff
115115
)
116116
buff
117117

118-
-- | Apppend a given count of a 'Char' to a 'Buffer'.
118+
-- | Apppend a given count of a 'Char' to a t'Buffer'.
119119
--
120120
-- >>> :set -XLinearTypes
121121
-- >>> runBuffer (\b -> appendChars 3 'x' (b |>. 'A'))

src/Data/Text/Builder/Linear/Core.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Licence: BSD3
55
-- Maintainer: Andrew Lelechenko <[email protected]>
66
--
7-
-- Low-level routines for 'Buffer' manipulations.
7+
-- Low-level routines for t'Buffer' manipulations.
88
module Data.Text.Builder.Linear.Core (
99
-- * Type
1010
Buffer,

src/Data/Text/Builder/Linear/Internal.hs

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Licence: BSD3
55
-- Maintainer: Andrew Lelechenko <[email protected]>
66
--
7-
-- Internal routines for 'Buffer' manipulations.
7+
-- Internal routines for t'Buffer' manipulations.
88
module Data.Text.Builder.Linear.Internal (
99
-- * Type
1010
Buffer,
@@ -41,15 +41,15 @@ import GHC.ST (ST (..), runST)
4141

4242
import Data.Text.Builder.Linear.Array
4343

44-
-- | Internally 'Buffer' is a mutable buffer.
45-
-- If a client gets hold of a variable of type 'Buffer',
44+
-- | Internally t'Buffer' is a mutable buffer.
45+
-- If a client gets hold of a variable of type t'Buffer',
4646
-- they'd be able to pass a mutable buffer to concurrent threads.
4747
-- That's why API below is carefully designed to prevent such possibility:
48-
-- clients always work with linear functions 'Buffer' ⊸ 'Buffer' instead
49-
-- and run them on an empty 'Buffer' to extract results.
48+
-- clients always work with linear functions t'Buffer' ⊸ t'Buffer' instead
49+
-- and run them on an empty t'Buffer' to extract results.
5050
--
5151
-- In terms of [@linear-base@](https://hackage.haskell.org/package/linear-base)
52-
-- 'Buffer' is [@Consumable@](https://hackage.haskell.org/package/linear-base/docs/Prelude-Linear.html#t:Consumable)
52+
-- t'Buffer' is [@Consumable@](https://hackage.haskell.org/package/linear-base/docs/Prelude-Linear.html#t:Consumable)
5353
-- (see 'consumeBuffer')
5454
-- and [@Dupable@](https://hackage.haskell.org/package/linear-base/docs/Prelude-Linear.html#t:Dupable)
5555
-- (see 'dupBuffer'),
@@ -63,19 +63,19 @@ import Data.Text.Builder.Linear.Array
6363
-- Remember: this is a strict builder, so on contrary to "Data.Text.Lazy.Builder"
6464
-- for optimal performance you should use strict left folds instead of lazy right ones.
6565
--
66-
-- 'Buffer' is an unlifted datatype,
66+
-- t'Buffer' is an unlifted datatype,
6767
-- so you can put it into an unboxed tuple @(# ..., ... #)@,
6868
-- but not into @(..., ...)@.
6969
data Buffer TYPE ('BoxedRep 'Unlifted) where
7070
Buffer {-# UNPACK #-} !Text Buffer
7171

72-
-- | Unwrap 'Buffer', no-op.
72+
-- | Unwrap t'Buffer', no-op.
7373
-- Most likely, this is not the function you're looking for
7474
-- and you need 'runBuffer' instead.
7575
unBuffer Buffer Text
7676
unBuffer (Buffer x) = x
7777

78-
-- | Run a linear function on an empty 'Buffer', producing a strict 'Text'.
78+
-- | Run a linear function on an empty t'Buffer', producing a strict t'Text'.
7979
--
8080
-- Be careful to write @runBuffer (\\b -> ...)@ instead of @runBuffer $ \\b -> ...@,
8181
-- because current implementation of linear types lacks special support for '($)'.
@@ -88,10 +88,8 @@ unBuffer (Buffer x) = x
8888
-- 'runBuffer' is similar in spirit to mutable arrays API in
8989
-- [@Data.Array.Mutable.Linear@](https://hackage.haskell.org/package/linear-base/docs/Data-Array-Mutable-Linear.html),
9090
-- which provides functions like
91-
-- [@fromList@](https://hackage.haskell.org/package/linear-base/docs/Data-Array-Mutable-Linear.html#v:fromList) ∷ [@a@] → (@Vector@ @a@ ⊸ [@Ur@](https://hackage.haskell.org/package/linear-base-0.3.0/docs/Prelude-Linear.html#t:Ur) b) ⊸ [@Ur@](https://hackage.haskell.org/package/linear-base-0.3.0/docs/Prelude-Linear.html#t:Ur) @b@.
92-
-- Here the initial buffer is always empty and @b@ is 'Text'. Since 'Text' is
93-
-- [@Movable@](https://hackage.haskell.org/package/linear-base/docs/Prelude-Linear.html#t:Movable),
94-
-- 'Text' and [@Ur@](https://hackage.haskell.org/package/linear-base-0.3.0/docs/Prelude-Linear.html#t:Ur) 'Text' are equivalent.
91+
-- [@fromList@](https://hackage.haskell.org/package/linear-base/docs/Data-Array-Mutable-Linear.html#v:fromList) ∷ @Movable@ @b@ ⇒ [@a@] → (@Array@ @a@ ⊸ @b@) ⊸ @b@.
92+
-- Here the initial buffer is always empty and @b@ is t'Text'.
9593
runBuffer (Buffer Buffer) Text
9694
runBuffer f = unBuffer (shrinkBuffer (f (Buffer mempty)))
9795
{-# NOINLINE runBuffer #-}
@@ -100,7 +98,7 @@ runBuffer f = unBuffer (shrinkBuffer (f (Buffer mempty)))
10098
See https://github.com/Bodigrim/linear-builder/issues/19
10199
and https://github.com/tweag/linear-base/pull/187#discussion_r489081926
102100
for the discussion why NOINLINE here and below in 'runBufferBS' is necessary.
103-
Without it CSE (common subexpression elimination) can pull out 'Buffer's from
101+
Without it CSE (common subexpression elimination) can pull out t'Buffer's from
104102
different 'runBuffer's and share them, which is absolutely not what we want.
105103
-}
106104

@@ -126,9 +124,9 @@ memptyPinned = runST $ do
126124
arr A.unsafeFreeze marr
127125
pure $ Text arr 0 0
128126

129-
-- | Create an empty 'Buffer'.
127+
-- | Create an empty t'Buffer'.
130128
--
131-
-- The first 'Buffer' is the input and the second is a new empty 'Buffer'.
129+
-- The first t'Buffer' is the input and the second is a new empty t'Buffer'.
132130
--
133131
-- This function is needed in some situations, e.g. with
134132
-- 'Data.Text.Builder.Linear.Buffer.justifyRight'. The following example creates
@@ -172,7 +170,7 @@ newEmptyBuffer (Buffer t@(Text arr _ _)) =
172170
-- >>> runBuffer (\b -> case dupBuffer b of (# b1, b2 #) -> ("foo" <| b1) >< (b2 |> "bar"))
173171
-- "foobar"
174172
--
175-
-- Note the unboxed tuple: 'Buffer' is an unlifted datatype,
173+
-- Note the unboxed tuple: t'Buffer' is an unlifted datatype,
176174
-- so it cannot be put into @(..., ...)@.
177175
dupBuffer Buffer (# Buffer, Buffer #)
178176
dupBuffer (Buffer x) = (# Buffer x, Buffer (T.copy x) #)
@@ -184,7 +182,7 @@ dupBuffer (Buffer x) = (# Buffer x, Buffer (T.copy x) #)
184182
consumeBuffer Buffer ()
185183
consumeBuffer Buffer {} = ()
186184

187-
-- | Erase buffer's content, replacing it with an empty 'Text'.
185+
-- | Erase buffer's content, replacing it with an empty t'Text'.
188186
eraseBuffer Buffer Buffer
189187
eraseBuffer (Buffer (Text arr _ _)) =
190188
Buffer (if isPinned arr then memptyPinned else mempty)
@@ -208,23 +206,23 @@ byteSizeOfBuffer (Buffer t@(Text _ _ len)) = (# Buffer t, fromIntegral len #)
208206
lengthOfBuffer Buffer (# Buffer, Word #)
209207
lengthOfBuffer (Buffer t) = (# Buffer t, fromIntegral (T.length t) #)
210208

211-
-- | Slice 'Buffer' by dropping given number of 'Char's.
209+
-- | Slice t'Buffer' by dropping given number of 'Char's.
212210
dropBuffer Word Buffer Buffer
213211
dropBuffer nChar (Buffer t@(Text arr off len))
214212
| nByte <= 0 = Buffer (Text arr (off + len) 0)
215213
| otherwise = Buffer (Text arr (off + nByte) (len - nByte))
216214
where
217215
nByte = T.measureOff (fromIntegral nChar) t
218216

219-
-- | Slice 'Buffer' by taking given number of 'Char's.
217+
-- | Slice t'Buffer' by taking given number of 'Char's.
220218
takeBuffer Word Buffer Buffer
221219
takeBuffer nChar (Buffer t@(Text arr off _))
222220
| nByte <= 0 = Buffer t
223221
| otherwise = Buffer (Text arr off nByte)
224222
where
225223
nByte = T.measureOff (fromIntegral nChar) t
226224

227-
-- | Low-level routine to append data of unknown size to a 'Buffer'.
225+
-- | Low-level routine to append data of unknown size to a t'Buffer'.
228226
appendBounded
229227
Int
230228
-- ^ Upper bound for the number of bytes, written by an action
@@ -248,7 +246,7 @@ appendBounded maxSrcLen appender (Buffer (Text dst dstOff dstLen)) = Buffer $ ru
248246
pure $ Text new dstOff (dstLen + srcLen)
249247
{-# INLINE appendBounded #-}
250248

251-
-- | Low-level routine to append data of unknown size to a 'Buffer', giving
249+
-- | Low-level routine to append data of unknown size to a t'Buffer', giving
252250
-- the action the choice between two strategies.
253251
--
254252
-- See also: 'appendBounded'.
@@ -301,7 +299,7 @@ appendBounded' maxSrcLen writer (Buffer (Text dst dstOff dstLen)) = Buffer $ run
301299
pure $ Text new dstOff' (dstLen + srcLen)
302300
{-# INLINE appendBounded' #-}
303301

304-
-- | Low-level routine to append data of known size to a 'Buffer'.
302+
-- | Low-level routine to append data of known size to a t'Buffer'.
305303
appendExact
306304
Int
307305
-- ^ Exact number of bytes, written by an action
@@ -315,7 +313,7 @@ appendExact srcLen appender =
315313
(\dst dstOff appender dst dstOff >> pure srcLen)
316314
{-# INLINE appendExact #-}
317315

318-
-- | Low-level routine to prepend data of unknown size to a 'Buffer'.
316+
-- | Low-level routine to prepend data of unknown size to a t'Buffer'.
319317
prependBounded
320318
Int
321319
-- ^ Upper bound for the number of bytes, written by an action
@@ -344,7 +342,7 @@ prependBounded maxSrcLen prepender appender (Buffer (Text dst dstOff dstLen))
344342
pure $ Text new newOff (dstLen + srcLen)
345343
{-# INLINE prependBounded #-}
346344

347-
-- | Low-level routine to prepend data of unknown size to a 'Buffer'.
345+
-- | Low-level routine to prepend data of unknown size to a t'Buffer'.
348346
--
349347
-- Contrary to 'prependBounded', only use a prepend action.
350348
--
@@ -374,7 +372,7 @@ prependBounded' maxSrcLen prepender (Buffer (Text dst dstOff dstLen))
374372
pure $ Text new (off - srcLen) (dstLen + srcLen)
375373
{-# INLINE prependBounded' #-}
376374

377-
-- | Low-level routine to append data of known size to a 'Buffer'.
375+
-- | Low-level routine to append data of known size to a t'Buffer'.
378376
prependExact
379377
Int
380378
-- ^ Exact number of bytes, written by an action
@@ -389,7 +387,7 @@ prependExact srcLen appender =
389387
(\dst dstOff appender dst dstOff >> pure srcLen)
390388
{-# INLINE prependExact #-}
391389

392-
-- | Concatenate two 'Buffer's, potentially mutating both of them.
390+
-- | Concatenate two t'Buffer's, potentially mutating both of them.
393391
--
394392
-- You likely need to use 'dupBuffer' to get hold on two builders at once:
395393
--

0 commit comments

Comments
 (0)