Add a saturating `adjust` variant?
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 领域
- backend
调研方向
The issue proposes a saturating shift variant of adjust in the DateTime library. Start by reading the existing adjust implementation and the Duration type; decide whether saturating behavior is appropriate and how bounds should be represented. Done means the API design is agreed on and the requested variant is specified.
由索引模型根据 Issue 内容生成。
描述
While writing an app with lots of DateTime manipulations, I noticed that adjust is very annoying to use, because of the Maybe return type. I don't think this is a very practical design, similarly to how (+) :: Int -> Int -> Maybe Int wouldn't be. There is often not much you can do on failure, other than just skip the operation. Needless to say, that doesn't help with correctness.
I think that saturating semantics would make more sense. Something like this:
-- | Like `adjust`, but saturates on out-of-bounds results.
shift :: forall d. Duration d => d -> DateTime -> DateTime
shift d dt = case adjust d dt of
Nothing -> if fromDuration d > mempty then top else bottom
Just d' -> d'
Does this sound like a good idea? I can make it into a PR, but wanted to get some feedback first.
- 主要语言
- 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 条评论 ·
-
Add constructors for Date / Time components using type-level integers可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 5/5 一周以上 新手友好度 15/100
purescript/purescript-datetime#96 · 1 条评论 ·
-
type: documentation
难度 2/5 1-3 小时 新手友好度 35/100
purescript/purescript-datetime#92 · 1 条评论 ·
-
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
-
难度 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 天内回复