foldr1 and foldl1 are too restrictive

Aberta
#151 1 comentário 3 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
36/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Domínio
backend

Direção de pesquisa

Start by comparing the proposed and current foldr1 signatures in the issue, then trace their definitions and the corresponding foldl1 implementation in the repository. Check existing tests for these functions and determine whether the proposed terminal-value mapping behavior can be supported without a full traversal; done means the API decision and its behavior are covered by tests. The issue has had no comment activity for over four years.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

type: breaking change

Should the signature of foldr1 (and similarly foldl1) be:

foldr1 :: forall f a b. Foldable1 f => (a -> b -> b) -> (a -> b) -> f a -> b

I understand the logic behind the current signature:

foldr1 :: forall f a b. Foldable1 f => (b -> b -> b) -> f b -> b

In that, if I have a mapping from a -> b, then I can pre-map unconditionally, and derive the latter signature. Unfortunately that's not actually what I want to do:

  • I only want the mapping to apply to the terminal value.
  • I want to otherwise combine with the combining function.
  • I don't want to waste an entire traversal to make the signature work.

I feel like there's a missed opportunity with the current signature. To be honest, I almost never want the current signature.

Linguagem predominante
PureScript
Estrelas
51
Forks
57
Merge médio
3d 14min
PRs com merge (30d)
1

Preparar o ambiente

  • Sem Dockerfile nem arquivo Docker Compose
  • Tem um modelo de pull request
  • Sem guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de purescript/purescript-foldable-traversable

Todas as issues de purescript/purescript-foldable-traversable

Issues semelhantes

Mais issues de Backend & API Design

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.