Add a saturating `adjust` variant?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Ambito
- backend
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- PureScript
- Stelle
- 51
- Fork
- 48
- Merge medio
- 2g 23h
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di purescript/purescript-datetime
-
Week number of the YearAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
purescript/purescript-datetime#102 · 5 commenti ·
-
Add constructors for Date / Time components using type-level integersForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
purescript/purescript-datetime#96 · 1 commento ·
-
type: documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
purescript/purescript-datetime#92 · 1 commento ·
-
Addjust by Month, YearApertastatus: needs more info
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
-
type: enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 24/100
purescript/purescript-datetime#79 · 6 commenti · 1 reazione ·
Tutte le issue di purescript/purescript-datetime
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
remove the use of `forget`Apertagood first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
milind-soni/OpenMausBot#5829 ·
I maintainer di solito rispondono entro 1 giorno