Create a partially applied record constructor
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Domaine
- backend
Piste de recherche
The issue describes a proposed partially applied record constructor and shows an existing applyFields implementation using Prim.Row and Record.disjointUnion. Start by reading the package’s current record construction APIs and the linked example; determine whether <*> can support field-based application while preserving the intended type constraints. Done means a documented API and tests demonstrate constructing a record without relying on field order.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Consider this:
F <$> x <*> y <*> z
This has a problem traditionally that you need to make sure you get the x/y/z order correct. If you're making forms (web forms) with e.g. a formlet library, this becomes pretty hard to manage.
What if we could do this?
partially F <$> pure {x:a} <*> pure {y:b} <*> pure {z:a}
(or alternatively by using SProxy :: SProxy "a", etc.)
So that partially F would produce a function of one argument of one of the x, y or z fields (or more, I guess). When provided with one, it accepts another argument until all fields have been consumed.
I made special version of <*> that achieves something similar:
module Record.Apply where
import Control.Applicative
import Prim.Row (class Nub, class Union)
import Record (disjointUnion)
-- API
applyFields
:: forall f inner outer combined.
Union inner outer combined
=> Nub combined combined
=> Apply f
=> f { | inner }
-> f { | outer }
-> f { | combined }
applyFields getInner getOuter =
disjointUnion <$> getInner <*> getOuter
infixl 5 applyFields as <|*>
-- Demo
newtype Foo = Foo { x :: Int, y :: String, z :: Array Int }
demo :: forall f. Applicative f => f Foo
demo = Foo <$> pure {y: ""} <|*> pure {x: 2} <|*> pure {z: []}
Which works nicely, but I think re-using <*> would be cool too. Any ideas?
- Langage dominant
- PureScript
- Étoiles
- 68
- Forks
- 33
- Merge moyen
- 2 j 23 h
- 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
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de purescript/purescript-record
-
Thoughts on replacing Proxy with VTA?Peut-être pris @pete-murphy l’a pris il y a 1043 jours. Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 10/100
purescript/purescript-record#85 · 3 commentaires · 2 réactions ·
-
Add `mergeFlipped`Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 35/100
purescript/purescript-record#84 · 5 commentaires · 1 réaction ·
-
insert and forall in recordOuvertestatus: needs more info
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
purescript/purescript-record#41 · 2 commentaires · 1 réaction ·
-
pick functionOuvertepurs-0.15 type: breaking change
Difficulté 4/5 3-5 jours Accessibilité débutants 20/100
purescript/purescript-record#5 · 6 commentaires ·
Toutes les issues de purescript/purescript-record
Issues similaires
-
ManageSieve proxy: a backend's NO/BYE greeting is skipped as a capability line and reported as EOFOuvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Mend: dependency security vulnerability
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
ManageIQ/manageiq-pods#1476 ·
Les mainteneurs répondent en général sous 1 jour
-
mcp: typed tool handlers lose wrapped JSON-RPC errorsPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
modelcontextprotocol/go-sdk#1529 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
FinanceFlash/unvibecode#818 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100