chowells79 / lrucache

A simple pure LRU cache written in Haskell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change `Maybe Integer` size restriction type to `Int`

meiersi opened this issue · comments

Your LRU cache cannot store more than (maxBound :: Int) - 1 elements, as the corresponding memory requirements would exceed the range of memory that your CPU can address. Hence, you can use a size restriction of maxBound :: Int to simulate an unbounded (i.e., memory-bounded) LRU cache. However, I can see only very few use cases of a memory-bounded LRU cache, as I would normally use a LRU cache to avoid using all memory.

Therfore, I suggest changing the API to always require a size restriction of type Int and tell the user about using maxBound :: Int, if he wants a purely memory-bounded instance of the datastructure.

This is solved in an entirely different way in the development version code.