More natural takeWhile analogue?
Open
Nobody has claimed this yet.
type: feature request
- Dominant language
- Haskell
- Stars
- 359
- Forks
- 45
- PR merge metrics
- No merged PRs in 30d
Description
We have
takeWhile :: Dupable a => (a %1 -> Bool) -> [a] %1 -> [a]
takeWhile _ [] = []
takeWhile p (x : xs) =
dup2 x & \(x', x'') ->
if p x'
then x'' : takeWhile p xs
else (x'', xs) `lseq` []
Should we add a version that (a bit like mapMaybe for filter) relaxes the constraint while adding flexibility?
mapWhileJust :: Consumable a => (a %1 -> Maybe b) -> [a] %1 -> [b]
mapWhileJust _ [] = []
mapWhileJust p (x : xs) =
case p x of
Nothing -> xs `lseq` []
Just x' -> x' : mapWhileJust p xs
Unfortunately, I don't see any similarly intuitive analogue of dropWhile.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing takeWhile implementation and related mapMaybe API, then compare them with the proposed mapWhileJust signature and semantics. The issue needs an agreed API, including whether a dropWhile analogue is required, before implementation can begin; done means the design is resolved and covered by appropriate tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100