`second`/`right` derived from `first`/`left`

Ouverte
#49 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
28/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
À l'abandon
Domaine
backend

Piste de recherche

The issue asks whether Strong and Choice can derive second and right from first and left, and whether PureScript’s lack of default type class implementations explains the current design. Start by reading the Strong and Choice definitions and their implementations; the issue names no files or tests. Done means establishing the design reason and whether changing the class definitions is viable.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Is there any reason why Strong/Choice require second/right and not instead derive them from first/left?

secondBasedOnFirst :: forall p a b c. Strong p => p a b -> p (Tuple c a) (Tuple c b)
-- equivalent to `second`?
secondBasedOnFirst = dimap swap swap <<< first
  where
    swap :: forall x y. Tuple x y -> Tuple y x
    swap (Tuple a b) = Tuple b a

rightBasedOnLeft :: forall p a b c. Choice p => p a b -> p (Either c a) (Either c b)
-- equivalent to `right`?
rightBasedOnLeft = dimap flip flip <<< left
  where
    flip :: forall x y. Either x y -> Either y x
    flip (Left a) = Right a
    flip (Right b) = Left b

Is this only because of lack of default type class member implementations feature in PureScript or is there any other reason?

Langage dominant
PureScript
Étoiles
34
Forks
13
Merge moyen
3 j 10 min
PR mergées (30 j)
1

Préparer son environnement

  • Aucun Dockerfile ni fichier Docker Compose
  • Propose un modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de purescript/purescript-profunctor

Toutes les issues de purescript/purescript-profunctor

Issues similaires

Plus d'issues Backend & API Design

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.