haskell: Now, Object is an instance of NFData.

This commit is contained in:
tanakh 2010-09-07 16:14:29 +09:00
parent c56926428c
commit 169f287970
2 changed files with 15 additions and 1 deletions

View File

@ -24,7 +24,9 @@ Library
iteratee >= 0.4 && < 0.5, iteratee >= 0.4 && < 0.5,
attoparsec >= 0.8.1 && < 0.8.2, attoparsec >= 0.8.1 && < 0.8.2,
binary >= 0.5.0 && < 0.5.1, 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 Ghc-options: -Wall -O2
Hs-source-dirs: src Hs-source-dirs: src

View File

@ -25,6 +25,7 @@ module Data.MessagePack.Object(
Result, Result,
) where ) where
import Control.DeepSeq
import Control.Monad import Control.Monad
import Control.Monad.Trans.Error () import Control.Monad.Trans.Error ()
import qualified Data.ByteString as B import qualified Data.ByteString as B
@ -41,6 +42,17 @@ data Object =
| ObjectMap [(Object, Object)] | ObjectMap [(Object, Object)]
deriving (Show) 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 -- | The class of types serializable to and from MessagePack object
class OBJECT a where class OBJECT a where
-- | Encode a value to MessagePack object -- | Encode a value to MessagePack object