Add a saturating `adjust` variant?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- backend
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- PureScript
- Stars
- 51
- Forks
- 48
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from purescript/purescript-datetime
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
purescript/purescript-datetime#102 · 5 comments ·
-
Add constructors for Date / Time components using type-level integersMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 5/5 Over a week Newbie friendliness 15/100
purescript/purescript-datetime#96 · 1 comment ·
-
type: documentation
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
purescript/purescript-datetime#92 · 1 comment ·
-
status: needs more info
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
type: enhancement
Difficulty 5/5 Over a week Newbie friendliness 24/100
purescript/purescript-datetime#79 · 6 comments · 1 reaction ·
All issues in purescript/purescript-datetime
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
milind-soni/OpenMausBot#5829 ·
Maintainers usually reply within 1 day