on master help sign in
Merge pull request #82 from xaviershay/example-usages

Add example usages

commitdd8679fabfc45040e0f589a6d01f4883173366b1 authorMichael Snoyman <michael@snoyman.com> dateSun 28 Feb 2016, 19:17 (11 years ago) parentc9f3d876896753
2 files changed+31−10
Data/Yaml.hs+17 README.md+14−10
Data/Yaml.hs+17
@@ -16,6 +16,23 @@
1616--
1717-- For documentation on the @aeson@ types, functions, classes, and
1818-- operators, please see the @Data.Aeson@ module of the @aeson@ package.
19+--
20+-- == Examples
21+--
22+-- Decode into a data structure by specifying the desired type to the 'decode'
23+-- method.
24+--
25+-- > {-# LANGUAGE OverloadedStrings #-}
26+-- >
27+-- > import qualified Data.Yaml as Y
28+-- >
29+-- > main = do
30+-- > putStrLn . show $ (Y.decode "[1,2,3]" :: Maybe [Integer])
31+--
32+-- You can go one step further and decode into a custom type by implementing
33+-- 'FromJSON' for that type. This is also appropriate where extra
34+-- normalization, formatting or manipulation of the YAML is required on decode.
35+
1936#if (defined (ghcjs_HOST_OS))
2037module Data.Yaml {-# WARNING "GHCJS is not supported yet (will break at runtime once called)." #-}
2138#else
README.md+14−10
@@ -3,17 +3,21 @@
33Provides support for parsing and emitting Yaml documents.
44
55This package includes the [full libyaml C library version 0.1.5 by Kirill
6−Simonov](http://pyyaml.org/wiki/LibYAML) in the package so you
7−don't need to worry about any non-Haskell dependencies.
6+Simonov](http://pyyaml.org/wiki/LibYAML) in the package so you don't need to
7+worry about any non-Haskell dependencies.
88
9−The package is broken down into two primary modules.
10−"Data.Yaml" provides a high-level interface based
11−around the JSON datatypes provided by the @aeson@
12−package. "Text.Libyaml" provides a lower-level,
13−streaming interface. For most users, "Data.Yaml" is recommended.
9+The package is broken down into two primary modules. `Data.Yaml` provides a
10+high-level interface based around the JSON datatypes provided by the `aeson`
11+package. `Text.Libyaml` provides a lower-level, streaming interface. For most
12+users, `Data.Yaml` is recommended.
13+
14+Usage examples can be found in the `Data.Yaml` documentation.
1415
1516Additional modules:
1617
17−* Data.Yaml.Include supports adding `!include` directives to your YAML files.
18−* DAta.Yaml.Builder and Data.Yaml.Parser allow more fine-grained control of parsing an rendering, as opposed to just using the aeson typeclass and datatype system for parsing and rendering.
19−* Data.Yaml.Aeson is currently a re-export of Data.Yaml to explicitly choose to use the aeson-compatible API.
18+* `Data.Yaml.Include` supports adding `!include` directives to your YAML files.
19+* `Data.Yaml.Builder` and `Data.Yaml.Parser` allow more fine-grained control of
20+ parsing an rendering, as opposed to just using the aeson typeclass and
21+ datatype system for parsing and rendering.
22+* `Data.Yaml.Aeson` is currently a re-export of `Data.Yaml` to explicitly
23+ choose to use the aeson-compatible API.