Create a partially applied record constructor
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 领域
- backend
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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?
- 主要语言
- PureScript
- 星标
- 68
- 派生
- 33
- 平均合并
- 2 天 23 小时
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
purescript/purescript-record 的其他 Issue
-
Thoughts on replacing Proxy with VTA?可能已有人在做 @pete-murphy 于 1043 天前认领。 未关闭
难度 5/5 一周以上 新手友好度 10/100
purescript/purescript-record#85 · 3 条评论 · 2 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 35/100
purescript/purescript-record#84 · 5 条评论 · 1 个 reaction ·
-
status: needs more info
难度 4/5 3-5 天 新手友好度 25/100
purescript/purescript-record#41 · 2 条评论 · 1 个 reaction ·
-
pick function未关闭purs-0.15 type: breaking change
难度 4/5 3-5 天 新手友好度 20/100
purescript/purescript-record#5 · 6 条评论 ·
查看 purescript/purescript-record 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
-
good first issue help wanted
难度 2/5 1-3 小时 新手友好度 80/100
维护者通常 1 天内回复
-
bug good first issue
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
milind-soni/OpenMausBot#5829 ·
维护者通常 1 天内回复