diff --git a/haskell/msgpack.cabal b/haskell/msgpack.cabal index 3baff77f..bd10c4aa 100644 --- a/haskell/msgpack.cabal +++ b/haskell/msgpack.cabal @@ -24,7 +24,9 @@ Library iteratee >= 0.4 && < 0.5, attoparsec >= 0.8.1 && < 0.8.2, binary >= 0.5.0 && < 0.5.1, - data-binary-ieee754 >= 0.4 && < 0.5 + data-binary-ieee754 >= 0.4 && < 0.5, + deepseq >= 1.1 && <1.2 + Ghc-options: -Wall -O2 Hs-source-dirs: src diff --git a/haskell/src/Data/MessagePack/Object.hs b/haskell/src/Data/MessagePack/Object.hs index df0e89dd..6806722b 100644 --- a/haskell/src/Data/MessagePack/Object.hs +++ b/haskell/src/Data/MessagePack/Object.hs @@ -25,6 +25,7 @@ module Data.MessagePack.Object( Result, ) where +import Control.DeepSeq import Control.Monad import Control.Monad.Trans.Error () import qualified Data.ByteString as B @@ -41,6 +42,17 @@ data Object = | ObjectMap [(Object, Object)] deriving (Show) +instance NFData Object where + rnf obj = + case obj of + ObjectNil -> () + ObjectBool b -> rnf b + ObjectInteger n -> rnf n + ObjectDouble d -> rnf d + ObjectRAW bs -> bs `seq` () + ObjectArray a -> rnf a + ObjectMap m -> rnf m + -- | The class of types serializable to and from MessagePack object class OBJECT a where -- | Encode a value to MessagePack object