on master help sign in
Add example usage to preamble, reference from README.
commitae29023cde8420182ef587018c3cc74c249d406f authorXavier Shay <xavier@rhnh.net> dateThu 25 Feb 2016, 21:07 (11 years ago) parentc9f3d87
2 files changed+19
Data/Yaml.hs+17 README.md+2
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+2
@@ -12,6 +12,8 @@ around the JSON datatypes provided by the @aeson@
1212package. "Text.Libyaml" provides a lower-level,
1313streaming interface. For most users, "Data.Yaml" is recommended.
1414
15+Usage examples can be found in the "Data.Yaml" documentation.
16+
1517Additional modules:
1618
1719* Data.Yaml.Include supports adding `!include` directives to your YAML files.