Consistency for Eq a / Ord a functions with suffix "By"

Abierto
#215 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
30/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Área
api

Línea de trabajo

Read the array API definitions for difference, elem, notElem, elemIndex, and elemLastIndex, then compare their signatures and naming with the existing By variants listed in the issue. Decide whether differenceBy fits the API’s conventions and identify the corresponding functions to address. Done means the API naming and custom equality support are consistent; the issue provides no file or test paths to start from.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

type: enhancement

As I look through the API, I see a pretty consistent pattern of "You can rely on a typeclass for Eq/Ord or you can supply your own".

So if a type signature has forall a. Eq a => ..., there's often a version that removes this constraint and adds in a function like forall a. (a -> a -> Boolean) ...

There even seems like a pretty consistent naming pattern:

insert    & insertBy 
sort      & sortBy
group     & groupBy
groupAll  & groupAllBy
nub       & nubBy
nubEq     & nubByEq  <- Sort of a break from the pattern, but still
union     & unionBy
delete    & deleteBy
intersect & intersectBy

But it feels sort of arbitrary when some functions don't follow that pattern

For example: difference

I'd expect to see

difference :: forall a. Eq a => Array a -> Array a -> Array a
differenceBy :: forall a. (a -> a -> Boolean) -> Array a -> Array a -> Array a

The same holds for elem, notElem, elemIndex, and elemLastIndex, but these are covered by find >>> isJust, find >>> isNothing, findIndex, and findLastIndex. I understand a departure in naming pattern here since Eq a is replaced with (a -> Boolean) instead of (a -> a -> Boolean).

Lenguaje dominante
PureScript
Estrellas
58
Forks
70
Merge medio
2 d 22 h
PR fusionados (30 d)
1

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de purescript/purescript-arrays

Todos los issues de purescript/purescript-arrays

Issues similares

Más issues de Backend & API Design

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.