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

@@ -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