| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
FSRS.Scheduler
Description
A card scheduler built on top of the FSRS-7 memory model.
The memory model in FSRS.Algorithm is fully specified by upstream; the scheduling policy around it is not, so this module follows the widely used reference scheduler from py-fsrs: a card walks through a list of learning steps, graduates into the review queue, and drops into relearning steps when it lapses.
Two things differ from py-fsrs, both because FSRS-7 is built for continuous intervals where FSRS-6 was built for whole days:
- Elapsed time is measured in fractional days rather than truncated to whole
days, and it is fed to the model directly. There is no same-day special
case, because
transitionCoefficientalready is one. - Scheduled intervals are not rounded to whole days. Set
schedulerMinimumIntervalto1(the default) to keep review-queue intervals at a day or more anyway, or lower it to let FSRS-7 schedule sub-day reviews.
Fuzzing is explicit rather than ambient: reviewCard is deterministic, and
reviewCardFuzzed takes the random sample as an argument, so scheduling
stays a pure function of its inputs.
Synopsis
- data CardState
- = Learning
- | Review
- | Relearning
- data Card = Card {
- cardState :: !CardState
- cardStep :: !(Maybe Int)
- cardMemory :: !(Maybe MemoryState)
- cardDue :: !UTCTime
- cardLastReview :: !(Maybe UTCTime)
- newCard :: UTCTime -> Card
- cardRetrievability :: Scheduler -> Card -> UTCTime -> Maybe Retrievability
- data Scheduler = Scheduler {}
- defaultScheduler :: Scheduler
- nextReviewInterval :: Scheduler -> Stability -> Days
- data ReviewLog = ReviewLog {}
- reviewCard :: Scheduler -> Card -> Rating -> UTCTime -> (Card, ReviewLog)
- reviewCardFuzzed :: Double -> Scheduler -> Card -> Rating -> UTCTime -> (Card, ReviewLog)
- previewIntervals :: Scheduler -> Card -> UTCTime -> [(Rating, NominalDiffTime)]
- fuzzRanges :: [(Days, Days, Double)]
- fuzzBounds :: Scheduler -> Days -> Maybe (Days, Days)
- fuzzInterval :: Scheduler -> Double -> Days -> Days
Cards
Where a card sits in the learn / review / relearn cycle.
Constructors
| Learning | Working through |
| Review | Graduated; intervals come from the memory model. |
| Relearning | Lapsed, working through |
Instances
| Bounded CardState Source # | |
| Enum CardState Source # | |
Defined in FSRS.Scheduler Methods succ :: CardState -> CardState # pred :: CardState -> CardState # fromEnum :: CardState -> Int # enumFrom :: CardState -> [CardState] # enumFromThen :: CardState -> CardState -> [CardState] # enumFromTo :: CardState -> CardState -> [CardState] # enumFromThenTo :: CardState -> CardState -> CardState -> [CardState] # | |
| Read CardState Source # | |
| Show CardState Source # | |
| Eq CardState Source # | |
| Ord CardState Source # | |
A card's scheduling state.
Constructors
| Card | |
cardRetrievability :: Scheduler -> Card -> UTCTime -> Maybe Retrievability Source #
A card's retrievability at the given time, or Nothing if it has never
been reviewed.
Scheduler
Scheduling policy.
schedulerMinimumInterval must not exceed schedulerMaximumInterval.
Constructors
| Scheduler | |
Fields
| |
Instances
defaultScheduler :: Scheduler Source #
The FSRS-7 defaults: 90% desired retention, one-minute and ten-minute learning steps, a ten-minute relearning step, and intervals between one day and a century.
nextReviewInterval :: Scheduler -> Stability -> Days Source #
The interval a graduated card of the given stability earns, clamped to the scheduler's interval bounds.
Reviewing
What happened in a single review.
Constructors
| ReviewLog | |
Fields
| |
Instances
reviewCard :: Scheduler -> Card -> Rating -> UTCTime -> (Card, ReviewLog) Source #
Review a card. Deterministic: no fuzz is applied.
reviewCardFuzzed :: Double -> Scheduler -> Card -> Rating -> UTCTime -> (Card, ReviewLog) Source #
Review a card, fuzzing the scheduled interval.
The first argument is a uniform sample from [0, 1], which the caller draws
however it likes; values outside that range are clamped. Fuzz only ever
applies to a card that ends up in the Review state with an interval of at
least 2.5 days — see fuzzInterval.
previewIntervals :: Scheduler -> Card -> UTCTime -> [(Rating, NominalDiffTime)] Source #
The interval each of the four ratings would earn, without reviewing. Handy for showing the four buttons' answers in a UI.
Fuzz
fuzzRanges :: [(Days, Days, Double)] Source #
(start, end, factor) triples describing how much an interval may be
nudged: every day of the interval that falls inside a range contributes
factor days of slack. Taken from py-fsrs.
fuzzBounds :: Scheduler -> Days -> Maybe (Days, Days) Source #
The window an interval may be fuzzed into, or Nothing for intervals
shorter than 2.5 days, which are left alone.
fuzzInterval :: Scheduler -> Double -> Days -> Days Source #
Nudge an interval by a random amount within fuzzBounds.
The first argument is a uniform sample from [0, 1]; it is clamped, so any
finite value is safe. Intervals below 2.5 days are returned unchanged.