Add a saturating `adjust` variant?
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Bereich
- backend
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- PureScript
- Sterne
- 51
- Forks
- 48
- Ø Merge
- 2 T. 23 Std.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus purescript/purescript-datetime
-
Week number of the YearOffen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 25/100
purescript/purescript-datetime#102 · 5 Kommentare ·
-
Add constructors for Date / Time components using type-level integersEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 15/100
purescript/purescript-datetime#96 · 1 Kommentar ·
-
type: documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
purescript/purescript-datetime#92 · 1 Kommentar ·
-
Addjust by Month, YearOffenstatus: needs more info
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
-
type: enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 24/100
purescript/purescript-datetime#79 · 6 Kommentare · 1 Reaktion ·
Alle Issues in purescript/purescript-datetime
Ähnliche Issues
-
ManageSieve proxy: a backend's NO/BYE greeting is skipped as a capability line and reported as EOFOffenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Mend: dependency security vulnerability
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
ManageIQ/manageiq-pods#1476 ·
Maintainer antworten meist innerhalb von 1 Tag
-
mcp: typed tool handlers lose wrapped JSON-RPC errorsEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
modelcontextprotocol/go-sdk#1529 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
FinanceFlash/unvibecode#818 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100