From c9464f62759401a17206e9f517f0e76c19124645 Mon Sep 17 00:00:00 2001 From: postsolar <120750161+postsolar@users.noreply.github.com> Date: Mon, 23 Oct 2023 02:47:05 +0300 Subject: [PATCH 1/5] Update a doc comment --- src/Data/String/CodeUnits.purs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Data/String/CodeUnits.purs b/src/Data/String/CodeUnits.purs index 5fed21f..90f9012 100644 --- a/src/Data/String/CodeUnits.purs +++ b/src/Data/String/CodeUnits.purs @@ -297,9 +297,9 @@ dropWhile :: (Char -> Boolean) -> String -> String dropWhile p s = drop (countPrefix p s) s -- | Returns the substring at indices `[begin, end)`. --- | If either index is negative, it is normalised to `length s - index`, --- | where `s` is the input string. `""` is returned if either --- | index is out of bounds or if `begin > end` after normalisation. +-- | If either index is negative, it is normalised to `length s + index`, +-- | where `s` is the input string. `""` is returned if +-- | `begin > end` after normalisation. -- | -- | ```purescript -- | slice 0 0 "purescript" == "" From 0d917232da3799d60f7b88d39f08d382c54d1563 Mon Sep 17 00:00:00 2001 From: postsolar <120750161+postsolar@users.noreply.github.com> Date: Mon, 30 Oct 2023 00:23:15 +0200 Subject: [PATCH 2/5] Better definition for `Data.String.NonEmpty.CodeUnits.fromFoldable1` --- src/Data/String/NonEmpty/CodeUnits.purs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Data/String/NonEmpty/CodeUnits.purs b/src/Data/String/NonEmpty/CodeUnits.purs index af3de43..45bd9d3 100644 --- a/src/Data/String/NonEmpty/CodeUnits.purs +++ b/src/Data/String/NonEmpty/CodeUnits.purs @@ -91,10 +91,7 @@ snoc c s = toNonEmptyString (s <> CU.singleton c) -- | Creates a `NonEmptyString` from a `Foldable1` container carrying -- | characters. fromFoldable1 :: forall f. Foldable1 f => f Char -> NonEmptyString -fromFoldable1 = F1.fold1 <<< coe - where - coe ∷ f Char -> f NonEmptyString - coe = unsafeCoerce +fromFoldable1 = unsafeCoerce <<< F1.foldMap1 CU.singleton -- | Converts the `NonEmptyString` into an array of characters. -- | From 1da4011699e5ba1512df6cc4cf2511d46bec8889 Mon Sep 17 00:00:00 2001 From: postsolar <120750161+postsolar@users.noreply.github.com> Date: Mon, 30 Oct 2023 00:53:53 +0200 Subject: [PATCH 3/5] Revert "Update a doc comment" Reason: unrelated. This reverts commit c9464f62759401a17206e9f517f0e76c19124645. --- src/Data/String/CodeUnits.purs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Data/String/CodeUnits.purs b/src/Data/String/CodeUnits.purs index 90f9012..5fed21f 100644 --- a/src/Data/String/CodeUnits.purs +++ b/src/Data/String/CodeUnits.purs @@ -297,9 +297,9 @@ dropWhile :: (Char -> Boolean) -> String -> String dropWhile p s = drop (countPrefix p s) s -- | Returns the substring at indices `[begin, end)`. --- | If either index is negative, it is normalised to `length s + index`, --- | where `s` is the input string. `""` is returned if --- | `begin > end` after normalisation. +-- | If either index is negative, it is normalised to `length s - index`, +-- | where `s` is the input string. `""` is returned if either +-- | index is out of bounds or if `begin > end` after normalisation. -- | -- | ```purescript -- | slice 0 0 "purescript" == "" From 0f8570b290d0adb2092926014a11719324ab78a7 Mon Sep 17 00:00:00 2001 From: postsolar <120750161+postsolar@users.noreply.github.com> Date: Mon, 30 Oct 2023 01:40:26 +0200 Subject: [PATCH 4/5] Update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f36a713..c0def5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ Bugfixes: Other improvements: +## [v6.0.2] + +Other improvements: +- Redefine `Data.String.NonEmpty.CodeUnits.fromFoldable1` in terms of `singleton` (#168 by @postsolar) + ## [v6.0.1](https://github.com/purescript/purescript-strings/releases/tag/v6.0.1) - 2022-08-16 Bugfixes: From 22d0f23d1404e038c68ffe04ff5af5329b2a5498 Mon Sep 17 00:00:00 2001 From: postsolar <120750161+postsolar@users.noreply.github.com> Date: Mon, 30 Oct 2023 11:38:25 +0200 Subject: [PATCH 5/5] Use NonEmpty's singleton --- src/Data/String/NonEmpty/CodeUnits.purs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Data/String/NonEmpty/CodeUnits.purs b/src/Data/String/NonEmpty/CodeUnits.purs index 45bd9d3..4e97244 100644 --- a/src/Data/String/NonEmpty/CodeUnits.purs +++ b/src/Data/String/NonEmpty/CodeUnits.purs @@ -37,7 +37,6 @@ import Data.String.NonEmpty.Internal (NonEmptyString(..), fromString) import Data.String.Pattern (Pattern) import Data.String.Unsafe as U import Partial.Unsafe (unsafePartial) -import Unsafe.Coerce (unsafeCoerce) -- For internal use only. Do not export. toNonEmptyString :: String -> NonEmptyString @@ -91,7 +90,7 @@ snoc c s = toNonEmptyString (s <> CU.singleton c) -- | Creates a `NonEmptyString` from a `Foldable1` container carrying -- | characters. fromFoldable1 :: forall f. Foldable1 f => f Char -> NonEmptyString -fromFoldable1 = unsafeCoerce <<< F1.foldMap1 CU.singleton +fromFoldable1 = F1.foldMap1 singleton -- | Converts the `NonEmptyString` into an array of characters. -- |