Skip to content

Better definition for Data.String.NonEmpty.CodeUnits.fromFoldable1 #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Data/String/CodeUnits.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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" == ""
Expand Down
5 changes: 1 addition & 4 deletions src/Data/String/NonEmpty/CodeUnits.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
-- |
Expand Down