summaryrefslogtreecommitdiff
path: root/packages/code/hubris/src/Hubris/Collections/LRUCache.hs
blob: 995512dcedfd046d784ae0f91f6030ed85b072b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module Hubris.Collections.LRUCache
  ( empty
  , insert
  ) where

import qualified Data.Map as M
import Data.Monoid (Sum (..))

type LRUCache a = M.Map a (Sum Int)

empty :: LRUCache a
empty = M.empty

insert :: a -> LRUCache a -> LRUCache a
insert = M.alter (fmap $ const 0)
  where