Changeset 10107 for src/Pugs/Prim/Yaml.hs
- Timestamp:
- 04/28/06 14:53:19 (3 years ago)
- Files:
-
- 1 modified
-
src/Pugs/Prim/Yaml.hs (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Prim/Yaml.hs
r10059 r10107 12 12 import qualified Data.IntSet as IntSet 13 13 import qualified Data.IntMap as IntMap 14 import qualified Data. FastPackedString as Str14 import qualified Data.ByteString as Str 15 15 import DrIFT.YAML 16 16 … … 26 26 fromYaml :: YamlNode -> Eval Val 27 27 fromYaml MkYamlNode{el=YamlNil} = return VUndef 28 fromYaml MkYamlNode{el=YamlStr str} = return $ VStr $ decodeUTF8 $ Str.unpackstr28 fromYaml MkYamlNode{el=YamlStr str} = return $ VStr $ decodeUTF8 $ unpackBuf str 29 29 fromYaml MkYamlNode{el=YamlSeq nodes} = do 30 30 vals <- mapM fromYaml nodes … … 42 42 return $ VRef (hashRef hv) 43 43 Just s | (pre, post) <- Str.splitAt 16 s -- 16 == length "tag:pugs:Object:" 44 , pre == Str.pack"tag:pugs:Object:" -> do45 let typ = Str.unpackpost44 , pre == packBuf "tag:pugs:Object:" -> do 45 let typ = unpackBuf post 46 46 vals <- forM nodes $ \(keyNode, valNode) -> do 47 47 key <- fromVal =<< fromYaml keyNode … … 49 49 return (key, val) 50 50 return . VObject =<< createObject (mkType typ) vals 51 Just s | s == Str.pack"tag:pugs:Rule" -> do51 Just s | s == packBuf "tag:pugs:Rule" -> do 52 52 vals <- forM nodes $ \(keyNode, valNode) -> do 53 53 key <- fromVal =<< fromYaml keyNode … … 63 63 adverbs <- Map.lookup "adverbs" spec 64 64 return $ VRule MkRulePGE{rxRule=rule, rxGlobal=global, rxStringify=stringify, rxAdverbs=adverbs} 65 Just x -> error ("can't deserialize: " ++ (Str.unpack x))65 Just x -> error ("can't deserialize: " ++ unpackBuf x) 66 66 67 67 dumpYaml :: Val -> Eval Val … … 74 74 75 75 strNode :: String -> YamlNode 76 strNode = mkNode . YamlStr . Str.pack76 strNode = mkNode . YamlStr . packBuf 77 77 78 78 {- … … 109 109 hash <- fromVal v :: Eval VHash 110 110 attrs <- toYaml $ VRef (hashRef hash) 111 return $ tagNode (Just $ Str.pack$ "tag:pugs:Object:" ++ showType (objType obj)) attrs111 return $ tagNode (Just $ packBuf $ "tag:pugs:Object:" ++ showType (objType obj)) attrs 112 112 toYaml (VRule MkRulePGE{rxRule=rule, rxGlobal=global, rxStringify=stringify, rxAdverbs=adverbs}) = do 113 113 adverbs' <- toYaml adverbs
