packages feed

HsSyck 0.3 → 0.4

raw patch · 3 files changed

+53/−5 lines, 3 files

Files

+ Changes view
@@ -0,0 +1,10 @@+[Changes for 0.04 - 2007-06-16]++* Add Haddock documentations; no functional changes.+  Contributed by: Jaap Weel++[Changes for 0.03 - 2007-05-21]++* First working Hackage release: Unbreak the build by adding+  missing extra-source-files.+  Requested by: Bryan O'Sullivan
Data/Yaml/Syck.hsc view
@@ -1,3 +1,15 @@+-- |+-- Module       : Data.Yaml.Syck+-- Copyright    : Copyright 2005, 2006, 2007 by Audrey Tang, Gaal Yahas+-- License      : MIT +-- Maintainer   : Audrey Tang <audreyt@audreyt.org>+-- Stability    : provisional+-- Portability  : ghc+--+-- This is an interface to the @syck@ C library for parsing and+-- dumping YAML data. It lets you transform textual YAML data into an+-- object of type 'YamlNode', and vice versa, fast.+ #include "syck.h"  module Data.Yaml.Syck (@@ -76,10 +88,15 @@ nilNode :: YamlNode nilNode = MkNode maxId ENil Nothing ASingleton ++-- | Convert a ByteString buffer into a regular Haskell string+ {-# INLINE unpackBuf #-} unpackBuf :: Buf -> String unpackBuf = Buf.unpack +-- | Convert a regular Haskell string into a ByteString buffer+ {-# INLINE packBuf #-} packBuf :: String -> Buf packBuf = Buf.pack@@ -107,15 +124,21 @@ type EmitterExtras = Ptr () -} +-- | Dump a YAML node into a ByteString buffer (fast)+ emitYamlBytes :: YamlNode -> IO Buf emitYamlBytes node = do     bracket syck_new_emitter syck_free_emitter $ \emitter -> do         -- set up output port         out    <- newIORef []+         #{poke SyckEmitter, style} emitter scalarFold-        -- #{poke SyckEmitter, sort_keys} emitter (1 :: CInt)         #{poke SyckEmitter, anchor_format} emitter (Ptr "%d"## :: CString) +        -- Uncomment this line if you want EMap to sort its keys.+        -- (this is usually unnecessary because Data.Map is already sorted.)+        -- #{poke SyckEmitter, sort_keys} emitter (1 :: CInt)+         marks <- Hash.new (==) (Hash.hashInt)          let freeze = freezeNode marks@@ -130,11 +153,15 @@         syck_emitter_flush emitter 0         fmap (Buf.concat . reverse) (readIORef out) +-- | Given a file name, dump a YAML node into that file+ emitYamlFile :: FilePath -> YamlNode -> IO () emitYamlFile file node = do     buf <- emitYamlBytes node     Buf.writeFile file buf +-- | Dump a YAML node into a regular Haskell string+ emitYaml :: YamlNode -> IO String emitYaml node = fmap unpackBuf (emitYamlBytes node) @@ -204,11 +231,17 @@ withTag :: YamlNode -> CString -> (CString -> IO a) -> IO a withTag node def f = maybe (f def) (`useAsCString` f) (n_tag node) +-- | Parse a regular Haskell string+ parseYaml :: String -> IO YamlNode parseYaml = (`withCString` parseYamlCStr) +-- | Given a file name, parse contents of file+ parseYamlFile :: String -> IO YamlNode parseYamlFile file = parseYamlBytes =<< Buf.readFile file++-- | Parse a ByteString buffer (this is faster)  parseYamlBytes :: Buf -> IO YamlNode parseYamlBytes = (`useAsCString` parseYamlCStr)
HsSyck.cabal view
@@ -1,10 +1,15 @@ Name:                HsSyck-Version:             0.3+Version:             0.4 Category:            Data Synopsis:            Fast, lightweight YAML loader and dumper Description:         Fast, lightweight YAML loader and dumper--- License is really "MIT", but Cabal allows no such field-License:             BSD3+        .+        This is an interface to the @syck@ C library for parsing and+        dumping YAML data. It lets you transform textual YAML data into an+        object of type 'YamlNode', and vice versa, fast.+Copyright:           Audrey Tang, Gaal Yahas, 2005, 2006, 2007+License:             OtherLicense+-- MIT License, see ./LICENSE License-file:        LICENSE Author:              Audrey Tang Maintainer:          audreyt@audreyt.org@@ -15,5 +20,5 @@ c-sources:           syck/bytecode.c syck/emitter.c syck/gram.c syck/handler.c                      syck/implicit.c syck/node.c syck/syck.c syck/syck_st.c syck/token.c                      syck/yaml2byte.c -extra-source-files:  syck/syck.h syck/syck_st.h syck/gram.h syck/yamlbyte.h+extra-source-files:  Changes syck/syck.h syck/syck_st.h syck/gram.h syck/yamlbyte.h include-dirs:        syck