Skip to content

Commit 373c44a

Browse files
authored
Better definition for Data.String.NonEmpty.CodeUnits.fromFoldable1 (#168)
1 parent 3d3e2f7 commit 373c44a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ Bugfixes:
1212

1313
Other improvements:
1414

15+
## [v6.0.2]
16+
17+
Other improvements:
18+
- Redefine `Data.String.NonEmpty.CodeUnits.fromFoldable1` in terms of `singleton` (#168 by @postsolar)
19+
1520
## [v6.0.1](https://github.com/purescript/purescript-strings/releases/tag/v6.0.1) - 2022-08-16
1621

1722
Bugfixes:

src/Data/String/NonEmpty/CodeUnits.purs

+1-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import Data.String.NonEmpty.Internal (NonEmptyString(..), fromString)
3737
import Data.String.Pattern (Pattern)
3838
import Data.String.Unsafe as U
3939
import Partial.Unsafe (unsafePartial)
40-
import Unsafe.Coerce (unsafeCoerce)
4140

4241
-- For internal use only. Do not export.
4342
toNonEmptyString :: String -> NonEmptyString
@@ -91,10 +90,7 @@ snoc c s = toNonEmptyString (s <> CU.singleton c)
9190
-- | Creates a `NonEmptyString` from a `Foldable1` container carrying
9291
-- | characters.
9392
fromFoldable1 :: forall f. Foldable1 f => f Char -> NonEmptyString
94-
fromFoldable1 = F1.fold1 <<< coe
95-
where
96-
coe f Char -> f NonEmptyString
97-
coe = unsafeCoerce
93+
fromFoldable1 = F1.foldMap1 singleton
9894

9995
-- | Converts the `NonEmptyString` into an array of characters.
10096
-- |

0 commit comments

Comments
 (0)