The monad-lrs package

A monad to calculate linear recursive sequence efficiently. Matrix
multiplication and fast exponentiation algorithm are used to speed
up calculating the number with particular index in the sequence. This
library also provides a monadic DSL to describe the sequence.