Create a partially applied record constructor
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Bereich
- backend
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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?
- Vorherrschende Sprache
- PureScript
- Sterne
- 68
- Forks
- 33
- Ø Merge
- 2 T. 23 Std.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus purescript/purescript-record
-
Thoughts on replacing Proxy with VTA?Evtl. vergeben @pete-murphy hat das vor 1043 Tagen übernommen. Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 10/100
purescript/purescript-record#85 · 3 Kommentare · 2 Reaktionen ·
-
Add `mergeFlipped`Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
purescript/purescript-record#84 · 5 Kommentare · 1 Reaktion ·
-
status: needs more info
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
purescript/purescript-record#41 · 2 Kommentare · 1 Reaktion ·
-
pick functionOffenpurs-0.15 type: breaking change
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 20/100
purescript/purescript-record#5 · 6 Kommentare ·
Alle Issues in purescript/purescript-record
Ähnliche Issues
-
ManageSieve proxy: a backend's NO/BYE greeting is skipped as a capability line and reported as EOFOffenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Mend: dependency security vulnerability
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
ManageIQ/manageiq-pods#1476 ·
Maintainer antworten meist innerhalb von 1 Tag
-
mcp: typed tool handlers lose wrapped JSON-RPC errorsEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
modelcontextprotocol/go-sdk#1529 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
FinanceFlash/unvibecode#818 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100