来自 Data.Binary:
instance (Binary e) => Binary (IntMap.IntMap e) where
put = put . IntMap.toAscList
get = liftM IntMap.fromDistinctAscList get
我认为这意味着任何IntMap (Binary e)
类型都可以序列化,但事实并非如此:
Data.Binary Data.IntMap> encode $ ((fromList [])::IntMap Int)
<interactive>:12:1:
No instance for (Binary (IntMap Int))
arising from a use of `encode'
如何使用提供的实例?