Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Allow replicateA for Seq to specialize

Open
#1,262 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
43/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
haskell
Domain
backend

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

low-hanging-fruit performance Seq

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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from haskell/containers

All issues in haskell/containers

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.