Cleanup a few bad types
1. Change type InfoDict from `Map BVal BVal` to `Map String BVal`
The keys are human readable keys like 'name', 'announce' etc and String
is the natural fit. This change also gets rid of a lot of packing
unpacking business.
Example:
-infoHash :: Map BVal BVal -> ByteString
-infoHash m = let info = m ! Bstr (pack "info")
- in (hash . pack . encode) info
+infoHash :: InfoDict -> ByteString
+infoHash m = hash . encode $ (m ! "info")
2. Change type of `encode` from `BVal -> String` to `BVal -> ByteString`
Encoded values might not be ASCII safe in the first place. Also, it
makes sense to be the inverse function of decode. `encode . decode` pair
might be a good candidate for Quickcheck.
Other changes are consequences of the type change. Fixed a bunch of
broken doctests in Bencode.
TIL haskell is kickass for refactoring!