Add a saturating `adjust` variant?
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- backend
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- PureScript
- Star
- 51
- Fork
- 48
- Merge trung bình
- 2 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của purescript/purescript-datetime
-
Week number of the YearĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
purescript/purescript-datetime#102 · 5 bình luận ·
-
Add constructors for Date / Time components using type-level integersCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
purescript/purescript-datetime#96 · 1 bình luận ·
-
type: documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
purescript/purescript-datetime#92 · 1 bình luận ·
-
Addjust by Month, YearĐang mởstatus: needs more info
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
-
type: enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 24/100
purescript/purescript-datetime#79 · 6 bình luận · 1 reaction ·
Tất cả issue của purescript/purescript-datetime
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
remove the use of `forget`Đang mởgood first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
milind-soni/OpenMausBot#5829 ·
Maintainer thường phản hồi trong vòng 1 ngày