-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Labels
status: needs more infoThis issue needs more info before any action can be done.This issue needs more info before any action can be done.
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.
i-am-the-slime, kaol and equt
Metadata
Metadata
Assignees
Labels
status: needs more infoThis issue needs more info before any action can be done.This issue needs more info before any action can be done.