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

Open
#49 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
28/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Domain
backend

Research direction

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.

Written by the indexing model from the issue text.

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?

Dominant language
PureScript
Stars
34
Forks
13
Avg merge
3d 10m
Merged PRs (30d)
1

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

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 purescript/purescript-profunctor

All issues in purescript/purescript-profunctor

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.