summaryrefslogtreecommitdiff
path: root/provider/posts/beuteltier/3.md
blob: 9b699c10d18ae299eeb8ca562d0aec42755b0961 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
---
title: An Update to the Type Level Utilities of an Overly Complicated Feedreader
published: 2015-08-12
tags: Beuteltier
---

I commited a change to `beuteltier/Beuteltier/Types/Util.hs` ("[…] Hashable update"). I
replaced the `Hashable` instances for `Object` and `MetaData` with a single, better
optimized function:

~~~ {.haskell}
objHash :: Applicative f => ObjectGen f -> f Int
-- ^ Two 'ObjectGen's hashes are a first indication of whether they are 'Equivalent'
objHash o = fmap hash $ (,) <$> (Set.toList . (^. mTags) <$> o ^. oMeta) <*> (Map.keys <$> o ^. oContent)
~~~

The new implementation allows computation of hashes without calling `generateObject` (that
function is evil — it makes sure the entire `Object` is "in RAM" (it isn´t actually, of
course (because haskell is lazy)—but I have no guarantee of that)).