Skip to content

Commit c4411ff

Browse files
committed
Add more docs on toText and instance Show
1 parent cff2d8d commit c4411ff

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Data/NonEmptyText.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ data NonEmptyText =
3737
NonEmptyText Char Text.Text
3838
deriving (Eq, Ord, NFData, Generic)
3939

40+
-- |
41+
-- Note that this instance uses 'toText', so two unequal NonEmptyTexts might be
42+
-- unequal even though they 'show' the same
4043
instance Show NonEmptyText where
4144
show = show . toText
4245

@@ -140,6 +143,8 @@ length = (1 +) . Text.length . Data.NonEmptyText.tail
140143
--
141144
-- The 'Data.Text.Text' result is guaranteed to be non-empty. However, this is
142145
-- not reflected in the type.
146+
-- Note that the first 'Char' may be replaced with U+FFFD,
147+
-- which happens when 'Data.Text.cons' would also replace it.
143148
toText :: NonEmptyText -> Text.Text
144149
toText = uncurry Text.cons . uncons
145150

0 commit comments

Comments
 (0)