Allow replicateA for Seq to specialize
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 43/100
Research direction
Start by reading the existing replicateA implementation and its SPECIALIZE pragma, then check how iterate is currently defined. Assess how a replicateS method fits the API and whether it should return the modified state as well; done means the chosen interface is implemented and tested, with any relevant rewrite rules validated.
Written by the indexing model from the issue text.
Description
Motivation
There's a SPECIALIZE pragma on replicateA which writes special faster code for it when the internal State monad is used, but users can't access it through normal means. It's also a more general version of iterate. I think it should be exposed.
Proposal
There should be a method replicateS:
replicateS :: Int -> (s -> (s, a)) -> s -> Seq a
replicateS n f = execState (replicateA n (State f))
-- 'iterate' would be defined using it.
iterate :: Int -> (a -> a) -> a -> Seq a
iterate n f = replicateS n (\a -> (f a, a))
-- Rewrite rules could be added.
{-# RULES "fmapSeq/replicateS" forall f n m s. fmapSeq f (replicateS n m s) = replicateS n (fmap f . m) s #-}
Options
There could be a version which uses runState instead of execState, and returns the modified state as well as the sequence.
- Dominant language
- Haskell
- Stars
- 356
- Forks
- 195
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from haskell/containers
-
major-release strictness Tree
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
haskell/containers#1260 ·
-
Map performance Set
Difficulty 5/5 Over a week Newbie friendliness 35/100
haskell/containers#1263 · 5 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
haskell/containers#1261 · 11 comments ·
-
IntSet low-hanging-fruit performance
Difficulty 3/5 1-2 days Newbie friendliness 58/100
haskell/containers#1251 ·
-
maintainability major-release
Difficulty 3/5 1-2 days Newbie friendliness 70/100
haskell/containers#1250 ·
All issues in haskell/containers
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
haskell-beam/beam#828 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
simplex-chat/simplex-chat#7755 ·
Maintainers usually reply within 1 day
-
bug core-libs
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
content good first issue
Difficulty 2/5 Under an hour Newbie friendliness 88/100
StudentSuite/awesome-skills-plugins-for-students#312 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 96/100
alunduil/collection-json.hs#415 ·
Maintainers usually reply within 1 day