Add constructors for Date / Time components using type-level integers
還沒有人認領這個 Issue。
- #97 來自 @JordanMartinez —— 已關閉,未合併
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 15/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 領域
- backend
研究方向
Start with the proposed type-level constructors in the issue and the exactDate API; the issue identifies type-level leap-year validation and a Prim.Int (class Mod) as prerequisites. Read the discussion and linked pull request #97 to see what was attempted. Done means providing a DateTime constructor that validates the day for its month and year at the type level.
由索引模型根據 Issue 內容生成。
描述
With the advent of 0.15.0 and type-level integers, we can now define Date and Time components without using unsafePartial:
hour
:: forall i
. Reflectable i Int
=> PI.Compare i (-1) PO.GT
=> PI.Compare i 24 PO.LT
=> Proxy i
-> Hour
hour p = Hour $ reflectType p
minute
:: forall i
. Reflectable i Int
=> PI.Compare i (-1) PO.GT
=> PI.Compare i 60 PO.LT
=> Proxy i
-> Minute
minute p = Minute $ reflectType p
second
:: forall i
. Reflectable i Int
=> PI.Compare i (-1) PO.GT
=> PI.Compare i 60 PO.LT
=> Proxy i
-> Second
second p = Second $ reflectType p
millisecond
:: forall i
. Reflectable i Int
=> PI.Compare i (-1) PO.GT
=> PI.Compare i 1_000 PO.LT
=> Proxy i
-> Millisecond
millisecond p = Millisecond $ reflectType p
year
:: forall i
. Reflectable i Int
=> PI.Compare i (-271821) PO.GT
=> PI.Compare i 275760 PO.LT
=> Proxy i
-> Year
year p = Year $ reflectType p
month
:: forall i
. Reflectable i Int
=> PI.Compare i 0 PO.GT
=> PI.Compare i 13 PO.LT
=> Proxy i
-> Month
month p = unsafePartial $ fromJust $ toEnum $ reflectType p
day
:: forall i
. Reflectable i Int
=> PI.Compare i 0 PO.GT
=> PI.Compare i 32 PO.LT
=> Proxy i
-> Day
day p = Day $ reflectType p
I would like to add a similar constructor for DateTime based on exactDate, but that requires verifying at the type-level that the day is within the bounds for the month-year combination. If we wanted to lift the isLeapYear function to the type-level, it seems we'll need a Prim.Int (class Mod) type class.
- 主要語言
- PureScript
- 星號
- 51
- 分支
- 48
- 平均合併
- 2 天 23 小時
- 30 天內合併 PR
- 1
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 沒有貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
purescript/purescript-datetime 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 25/100
purescript/purescript-datetime#102 · 5 則留言 ·
-
type: documentation
難度 2/5 1-3 小時 新手友好度 35/100
purescript/purescript-datetime#92 · 1 則留言 ·
-
status: needs more info
難度 5/5 一週以上 新手友好度 25/100
purescript/purescript-datetime#90 · 3 個 reaction ·
-
status: needs more info
難度 5/5 一週以上 新手友好度 20/100
-
type: enhancement
難度 5/5 一週以上 新手友好度 24/100
purescript/purescript-datetime#79 · 6 則留言 · 1 個 reaction ·
查看 purescript/purescript-datetime 的全部 Issue
相似的 Issue
-
ManageSieve proxy: a backend's NO/BYE greeting is skipped as a capability line and reported as EOF未關閉bug
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
Mend: dependency security vulnerability
難度 2/5 1-3 小時 新手友好度 62/100
ManageIQ/manageiq-pods#1476 ·
維護者通常 1 天內回覆
-
mcp: typed tool handlers lose wrapped JSON-RPC errors可能重新可做 關聯的 PR 已關閉且未合併。 未關閉
難度 2/5 1-3 小時 新手友好度 85/100
modelcontextprotocol/go-sdk#1529 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 66/100
FinanceFlash/unvibecode#818 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100