`Str.split` and `List.split` have different behavior
I was using a Str and I wanted to convert my code to work on some ASCII bytes directly with a List U8, so I tried switching from Str.split to List.split, but it didn't work because these functions do different things even though they are both named split. I think this behavior is confusing and inconsistent.
Current functions:
Str.split : Str, Str -> List Str
List.split : List elem, Nat -> { before : List elem, others : List elem }
I would expect the current List.split to be named something like List.splitAt, and one of these options for List.split instead:
List.split : List elem, elem -> List (List elem)
List.split : List elem, List elem -> List (List elem)
List.split : List elem, (elem -> Bool) -> List (List elem)
It also seems a inconsistent that List.split currently uses .others while List.splitFirst and List.splitLast use .after, but maybe there's a reason for that?
If someone takes over this issue, they probably should ask on zulip (contributing or ideas) threads about the preferred naming here.
I would be willing to give this a go
Looks like this was discussed on Zulip but not implemented
https://roc.zulipchat.com/#narrow/stream/304641-ideas/topic/Change.20List.2Esplit.20to.20List.2EsplitAt.3F/near/406667314
Consensus from the thread seems to be leave Str.split as-is and replace List.split with something like
List.splitAt : List a, U64 -> {before: List a, after: List a}
List.splitOn : List a, [Elem a, Sequence (List a)] -> List (List a)
I've set up a vote for the last point of doubt.
In conclusion:
We rename the current List.split to List.splitAt and also add:
List.splitOn: List a, a -> List (List a)
List.splitOnSeq: List a, List a -> List (List a)
I will take a look at this
I'm going to go with List.splitOnList instead of List.splitOnSeq as that seems to be the latest consensus from the thread.