Safely discarding Applicative results

6 thoughts
last posted April 1, 2016, 1:19 a.m.
0

The problem

erikd on Freenode #haskell.au shares an interesting bug.

The relevant code is:

buildTable :: IO EvenCache
buildTable = do
  ht <- HT.new
  forM_ pairs $ \ (k,v) ->
    maybe (HT.insert ht k v) (const $ abort k) <$>
        HT.lookup ht k
  return ht

Can you spot the error?

5 later thoughts