Serialization of a TChan String

Posted by J Fritsch on Stack Overflow See other posts from Stack Overflow or by J Fritsch
Published on 2012-06-23T21:51:59Z Indexed on 2012/06/26 3:16 UTC
Read the original article Hit count: 131

Filed under:

I have declared the following

type KEY = (IPv4, Integer)
type TPSQ = TVar (PSQ.PSQ KEY POSIXTime)
type TMap = TVar (Map.Map KEY [String])

data Qcfg = Qcfg { qthresh :: Int, tdelay :: Rational, cwpsq :: TPSQ, cwmap :: TMap, cw
chan :: TChan String } deriving (Show)

and would like this to be serializable in a sense that Qcfg can either be written to disk or be sent over the network. When I compile this I get the error

No instances for (Show TMap, Show TPSQ, Show (TChan String))
      arising from the 'deriving' clause of a data type declaration
    Possible fix:
      add instance declarations for
      (Show TMap, Show TPSQ, Show (TChan String))
      or use a standalone 'deriving instance' declaration,
           so you can specify the instance context yourself
    When deriving the instance for (Show Qcfg)

I am now not quite sure whether there is a chance at all to serialize my TChan although all individual nodes in it are members of the show class.

For TMap and TPSQ I wonder whether there are ways to show the values in the TVar directly (because it does not get changed, so there should no need to lock it) without having to declare an instance that does a readTVar ?

© Stack Overflow or respective owner

Related posts about haskell