`insertInforming` is not working correctly
mohsen3 opened this issue · comments
Running the following in ghci:
import Data.Cache.LRU
let l0 = newLRU (Just 2) :: LRU Int Int
let (l1, d1) = insertInforming 1 1 l0
let (l2, d2) = insertInforming 2 2 l1
let (l3, d3) = insertInforming 3 3 l2
print [(l1, d1), (l2, d2), (l3, d3)]
Results in:
[(fromList [(1,1)],Nothing),(fromList [(2,2),(1,1)],Nothing),(fromList [(3,3),(2,2)],Just (3,3))]
d3
should be Just (1, 1)
rather than Just (3, 3)
. It seems that insertInforming
is returning the input as the dropped element when the cache is full, while it is supposed to return the dropped out element. See https://github.com/chowells79/lrucache/blob/master/src/Data/Cache/LRU/Internal.hs#L146
In the case cache is not full, it is working fine.
Additionally, the IO module, do not expose an insertInforming
function. I can create a PR for these changes if you are willing to merge it.
Any updates on this? This is a serious bug which basically makes it impossible to use insertInforming
.
Sorry, I was badly burned out for a while. afd05d6 fixes this. New release coming soon.
New release available: https://hackage.haskell.org/package/lrucache-1.2.0.1