haskell-fsrs
Safe HaskellSafe-Inferred
LanguageHaskell2010

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 transitionCoefficient already is one.
  • Scheduled intervals are not rounded to whole days. Set schedulerMinimumInterval to 1 (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

Cards

data CardState Source #

Where a card sits in the learn / review / relearn cycle.

Constructors

Learning

Working through schedulerLearningSteps.

Review

Graduated; intervals come from the memory model.

Relearning

Lapsed, working through schedulerRelearningSteps.

data Card Source #

A card's scheduling state.

Constructors

Card 

Fields

Instances

Instances details
Show Card Source # 
Instance details

Defined in FSRS.Scheduler

Methods

showsPrec :: Int -> Card -> ShowS #

show :: Card -> String #

showList :: [Card] -> ShowS #

Eq Card Source # 
Instance details

Defined in FSRS.Scheduler

Methods

(==) :: Card -> Card -> Bool #

(/=) :: Card -> Card -> Bool #

newCard :: UTCTime -> Card Source #

A card that has never been reviewed, due at the given time.

cardRetrievability :: Scheduler -> Card -> UTCTime -> Maybe Retrievability Source #

A card's retrievability at the given time, or Nothing if it has never been reviewed.

Scheduler

data Scheduler Source #

Scheduling policy.

schedulerMinimumInterval must not exceed schedulerMaximumInterval.

Constructors

Scheduler 

Fields

Instances

Instances details
Show Scheduler Source # 
Instance details

Defined in FSRS.Scheduler

Eq Scheduler Source # 
Instance details

Defined in FSRS.Scheduler

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

data ReviewLog Source #

What happened in a single review.

Constructors

ReviewLog 

Fields

Instances

Instances details
Show ReviewLog Source # 
Instance details

Defined in FSRS.Scheduler

Eq ReviewLog Source # 
Instance details

Defined in FSRS.Scheduler

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.