I need to serialize a DAWG
(provided by this library) to a bytestring. As I saw in the documentation that there is an instance (Ord b, Binary b) => Binary (DAWG a b)
which seems to provide support for this, I tried directly to use encode
:
import qualified Data.DAWG.Dynamic as Dawg
import qualified Data.Binary as Bin
Bin.encode $ Dawg.fromList [("foo",1),("bar",2)]
But GHC complains that there is no instance for (Bin.Binary (Dawg.DAWG Char b0))
. I get the point that it is necessary to tell GHC what data types the graph contains, but then, how is it done? And if I'm wrong, what am I supposed to do instead?
Edit :
Stack trace for Bin.encode $ Dawg.fromList [("foo"::String,1::Int),("bar",2)]
:
<interactive>:19:1:
No instance for (Bin.Binary (Dawg.DAWG Char Int))
arising from a use of `Bin.encode'
Possible fix:
add an instance declaration for (Bin.Binary (Dawg.DAWG Char Int))
In the expression: Bin.encode
In the expression:
Bin.encode
$ Dawg.fromList [("foo" :: String, 1 :: Int), ("bar", 2)]
In an equation for `it':
it
= Bin.encode
$ Dawg.fromList [("foo" :: String, 1 :: Int), ("bar", 2)]