Repository navigation
Conversation
|
I'm happy to have a While
Sorry if this sounds discouraging. Unfortunately breaking changes in |
Good.
I've renamed my new
Removed that part of the change.
Well, isn't that the same as saying that if
Isn't the process of deprecating over a long enough time frame a huge reduction of that pain? |
|
It will be the maintainers of @Lysxia what do you think? |
|
I've managed to give a first look at test failures. Beside the fact that
splitOnNE :: HasCallStack
=> Text
-- ^ String to split on. If this string is empty, an error
-- will occur.
-> Text
-- ^ Input text.
-> NonEmptyList.NonEmpty Text
splitOnNE pat@(Text _ _ l) src@(Text arr off len)
| null pat = emptyError "splitOnNE"
…
…
…And to avoid code duplication, I changed the implementation of splitOn pat = NonEmptyList.toList . splitOnNE patbut this would cause test failures in GHC < 9.14, e.g. for 9.12.2: Changing splitOn pat src
| null pat = emptyError "splitOn" -- XXX Why if I comment this tests fail?
| otherwise = NonEmptyList.toList $ splitOnNE pat srcfixes the tests (at least those I've run locally). I don't understand why, given I am |
|
I think that's because of different laziness properties. Tests evaluate results before comparison, but only to a week normal form. In one case the error is immediate, in another it only pops once you start looking inside |
|
I think if we added
The situation with
The tests fail with older base indeed because |
phadej
left a comment
There was a problem hiding this comment.
The additions/changes are wrong.
Addition of examples/doctests should not affect the actual code. There is no OverloadedStrings needs in the implementation, thus the extension doesn't need to be enabled.
Also :seti is there specifically to not interfere with code loading. Don't change.
While I'm not a text maintainer, i'm not happy to see a change with some irrelevant changes. Please cleanup the patch.
Bodigrim
left a comment
There was a problem hiding this comment.
Thanks for your work on this issue! I have a few suggestions.
| -> NE.NonEmpty Text | ||
| splitOnNE pat src = case uncons pat of | ||
| Nothing -> emptyError "splitOnNE" | ||
| Just (c, "") -> splitNE (== c) src |
There was a problem hiding this comment.
Let's avoid OverloadedStrings if it's only for the sake of "". When working on text, one'd better be explicit what is String and what is Text. You can use a guard with Just (c, cs) | null cs -> ..., for example.
| go :: Int64 -> [Int64] -> Text -> NE.NonEmpty Text | ||
| go _ [] cs = cs :| [] | ||
| go !i (x:xs) cs = let h :*: t = splitAtWord (x-i) cs | ||
| in NE.cons h $ go (x+l) xs (dropWords l t) |
There was a problem hiding this comment.
These loops should produce a list [Text] instead of NonEmpty Text. Here every go outputs a :| to be immediately consumed by NE.cons.
| where comb :: [T.Text] -> NE.NonEmpty T.Text -> Text -> NE.NonEmpty Text | ||
| comb acc (s :| []) Empty = revChunks (s:acc) :| [] | ||
| comb acc (s :| []) (Chunk t ts) = comb (s:acc) (T.splitNE p t) ts | ||
| comb acc (s :| ss : sss) ts = NE.cons (revChunks (s:acc)) $ comb [] (ss :| sss) ts |
There was a problem hiding this comment.
Here too comb should produce [Text], otherwise every comp produces a :| only to be immediately consumed by NE.cons. Similarly the NonEmpty Text argument should be either left as a list or unpacked as two arguments.
| _ -> go 0 (indices pat src) | ||
| where | ||
| go :: Int -> [Int] -> NonEmptyList.NonEmpty Text | ||
| go !s (x:xs) = NonEmptyList.cons (text arr (s+off) (x-s)) |
There was a problem hiding this comment.
One more go that should return [Text].
This PR is somewhat in line with the spirit of #558.
Specifically, like that PR introduced
initsNE/tailsNEas variants ofinits/tailsthat returnNonEmpty Textinstead of[Text](for both lazy and strict modules), this change is introducingsplit'/splitOn'as variants ofsplit/splitOnthat returnNonEmpty Textinstead of[Text](for both lazy and strict modules).Furthermore, I'm proposing to substitute, at some point in the future,
split/splitOnwith thesplit'/splitOn'that I'm introducing now. In this view, the present PR represents step 1 in the following plan:split/splitOnand introducesplit'/splitOn'that aim to eventually substitute them;split/splitOn's implementations to simply forward call the newsplit'/splitOn'and turn themNE.toLists; this way existing tests should be enough;split/splitOn→split'/splitOn';split/splitOninto synonyms ofsplit'/splitOn', and deprecate the latter;split'/splitOn'for good.Additionally, I'm also proposing to rename
initsNE/tailsNEtoinits'/tails', and deprecate all ofinitsNE/tailsNE/inits/tails, starting the same plan as I proposed forsplit/splitOn.I've kept the change split in a few commits to make it easier to inspect and, possibly, drop something.