/usr/share/doc/libghc-yaml-doc/html/Data-Yaml.html is in libghc-yaml-doc 0.8.15.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Data.Yaml</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Data-Yaml.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Data-Yaml.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">yaml-0.8.15.2: Support for parsing and rendering YAML documents.</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">Data.Yaml</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Types</a></li><li><a href="#g:2">Constructors and accessors</a></li><li><a href="#g:3">Parsing</a></li><li><a href="#g:4">Classes</a></li><li><a href="#g:5">Encoding/decoding</a><ul><li><a href="#g:6">Better error information</a></li><li><a href="#g:7">More control over decoding</a></li></ul></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Provides a high-level interface for processing YAML files.</p><p>This module reuses most of the infrastructure from the <code>aeson</code> package.
This means that you can use all of the existing tools for JSON
processing for processing YAML files. As a result, much of the
documentation below mentions JSON; do not let that confuse you, it's
intentional.</p><p>For the most part, YAML content translates directly into JSON, and
therefore there is very little data loss. If you need to deal with YAML
more directly (e.g., directly deal with aliases), you should use the
<a href="Text-Libyaml.html">Text.Libyaml</a> module instead.</p><p>For documentation on the <code>aeson</code> types, functions, classes, and
operators, please see the <code>Data.Aeson</code> module of the <code>aeson</code> package.</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span> <a href="#t:Value">Value</a> :: *<ul class="subs"><li>= <a href="#v:Object">Object</a> !<a href="Data-Yaml.html#t:Object">Object</a></li><li>| <a href="#v:Array">Array</a> !<a href="Data-Yaml.html#t:Array">Array</a></li><li>| <a href="#v:String">String</a> !<a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></li><li>| <a href="#v:Number">Number</a> !<a href="file:///usr/share/doc/libghc-scientific-doc/html/Data-Scientific.html#t:Scientific">Scientific</a></li><li>| <a href="#v:Bool">Bool</a> !<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a></li><li>| <a href="#v:Null">Null</a></li></ul></li><li class="src short"><span class="keyword">data</span> <a href="#t:Parser">Parser</a> a :: * -> *</li><li class="src short"><span class="keyword">type</span> <a href="#t:Object">Object</a> = <a href="file:///usr/share/doc/libghc-unordered-containers-doc/html/Data-HashMap-Strict.html#t:HashMap">HashMap</a> <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> <a href="Data-Yaml.html#t:Value">Value</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:Array">Array</a> = <a href="file:///usr/share/doc/libghc-vector-doc/html/Data-Vector.html#t:Vector">Vector</a> <a href="Data-Yaml.html#t:Value">Value</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:ParseException">ParseException</a><ul class="subs"><li>= <a href="#v:NonScalarKey">NonScalarKey</a></li><li>| <a href="#v:UnknownAlias">UnknownAlias</a> { <ul class="subs"><li><a href="#v:_anchorName">_anchorName</a> :: <a href="Text-Libyaml.html#t:AnchorName">AnchorName</a></li></ul> }</li><li>| <a href="#v:UnexpectedEvent">UnexpectedEvent</a> { <ul class="subs"><li><a href="#v:_received">_received</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="Text-Libyaml.html#t:Event">Event</a></li><li><a href="#v:_expected">_expected</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="Text-Libyaml.html#t:Event">Event</a></li></ul> }</li><li>| <a href="#v:InvalidYaml">InvalidYaml</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="Data-Yaml.html#t:YamlException">YamlException</a>)</li><li>| <a href="#v:AesonException">AesonException</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a></li><li>| <a href="#v:OtherParseException">OtherParseException</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Exception-Base.html#t:SomeException">SomeException</a></li><li>| <a href="#v:NonStringKeyAlias">NonStringKeyAlias</a> <a href="Text-Libyaml.html#t:AnchorName">AnchorName</a> <a href="Data-Yaml.html#t:Value">Value</a></li><li>| <a href="#v:CyclicIncludes">CyclicIncludes</a></li></ul></li><li class="src short"><a href="#v:prettyPrintParseException">prettyPrintParseException</a> :: <a href="Data-Yaml.html#t:ParseException">ParseException</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:YamlException">YamlException</a><ul class="subs"><li>= <a href="#v:YamlException">YamlException</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a></li><li>| <a href="#v:YamlParseException">YamlParseException</a> { <ul class="subs"><li><a href="#v:yamlProblem">yamlProblem</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a></li><li><a href="#v:yamlContext">yamlContext</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a></li><li><a href="#v:yamlProblemMark">yamlProblemMark</a> :: <a href="Data-Yaml.html#t:YamlMark">YamlMark</a></li></ul> }</li></ul></li><li class="src short"><span class="keyword">data</span> <a href="#t:YamlMark">YamlMark</a> = <a href="#v:YamlMark">YamlMark</a> {<ul class="subs"><li><a href="#v:yamlIndex">yamlIndex</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a></li><li><a href="#v:yamlLine">yamlLine</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a></li><li><a href="#v:yamlColumn">yamlColumn</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a></li></ul>}</li><li class="src short"><a href="#v:object">object</a> :: [<a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:Pair">Pair</a>] -> <a href="Data-Yaml.html#t:Value">Value</a></li><li class="src short"><a href="#v:array">array</a> :: [<a href="Data-Yaml.html#t:Value">Value</a>] -> <a href="Data-Yaml.html#t:Value">Value</a></li><li class="src short"><a href="#v:.-61-">(.=)</a> :: <a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:KeyValue">KeyValue</a> kv => <span class="keyword">forall</span> v. <a href="Data-Yaml.html#t:ToJSON">ToJSON</a> v => <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> v -> kv</li><li class="src short"><a href="#v:.:">(.:)</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="Data-Yaml.html#t:Object">Object</a> -> <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> <a href="Data-Yaml.html#t:Parser">Parser</a> a</li><li class="src short"><a href="#v:.:-63-">(.:?)</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="Data-Yaml.html#t:Object">Object</a> -> <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> <a href="Data-Yaml.html#t:Parser">Parser</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> a)</li><li class="src short"><a href="#v:.-33--61-">(.!=)</a> :: <a href="Data-Yaml.html#t:Parser">Parser</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> a -> <a href="Data-Yaml.html#t:Parser">Parser</a> a</li><li class="src short"><a href="#v:parseMonad">parseMonad</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Monad.html#t:Monad">Monad</a> m => (a -> <a href="Data-Yaml.html#t:Parser">Parser</a> b) -> a -> m b</li><li class="src short"><a href="#v:parseEither">parseEither</a> :: (a -> <a href="Data-Yaml.html#t:Parser">Parser</a> b) -> a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#t:Either">Either</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> b</li><li class="src short"><a href="#v:parseMaybe">parseMaybe</a> :: (a -> <a href="Data-Yaml.html#t:Parser">Parser</a> b) -> a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> b</li><li class="src short"><span class="keyword">class</span> <a href="#t:ToJSON">ToJSON</a> a <span class="keyword">where</span><ul class="subs"><li><a href="#v:toJSON">toJSON</a> :: a -> <a href="Data-Yaml.html#t:Value">Value</a></li><li><a href="#v:toEncoding">toEncoding</a> :: a -> <a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:Encoding">Encoding</a></li></ul></li><li class="src short"><span class="keyword">class</span> <a href="#t:FromJSON">FromJSON</a> a <span class="keyword">where</span><ul class="subs"><li><a href="#v:parseJSON">parseJSON</a> :: <a href="Data-Yaml.html#t:Value">Value</a> -> <a href="Data-Yaml.html#t:Parser">Parser</a> a</li></ul></li><li class="src short"><a href="#v:encode">encode</a> :: <a href="Data-Yaml.html#t:ToJSON">ToJSON</a> a => a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a></li><li class="src short"><a href="#v:encodeFile">encodeFile</a> :: <a href="Data-Yaml.html#t:ToJSON">ToJSON</a> a => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:FilePath">FilePath</a> -> a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:decode">decode</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> a</li><li class="src short"><a href="#v:decodeFile">decodeFile</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> a)</li><li class="src short"><a href="#v:decodeEither">decodeEither</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#t:Either">Either</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> a</li><li class="src short"><a href="#v:decodeEither-39-">decodeEither'</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#t:Either">Either</a> <a href="Data-Yaml.html#t:ParseException">ParseException</a> a</li><li class="src short"><a href="#v:decodeFileEither">decodeFileEither</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#t:Either">Either</a> <a href="Data-Yaml.html#t:ParseException">ParseException</a> a)</li><li class="src short"><a href="#v:decodeHelper">decodeHelper</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="file:///usr/share/doc/libghc-conduit-doc/html/Data-Conduit.html#t:Source">Source</a> Parse <a href="Text-Libyaml.html#t:Event">Event</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#t:Either">Either</a> <a href="Data-Yaml.html#t:ParseException">ParseException</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#t:Either">Either</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> a))</li></ul></div><div id="interface"><h1 id="g:1">Types</h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Value" class="def">Value</a> :: *</p><div class="doc"><p>A JSON value represented as a Haskell value.</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Object" class="def">Object</a> !<a href="Data-Yaml.html#t:Object">Object</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:Array" class="def">Array</a> !<a href="Data-Yaml.html#t:Array">Array</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:String" class="def">String</a> !<a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:Number" class="def">Number</a> !<a href="file:///usr/share/doc/libghc-scientific-doc/html/Data-Scientific.html#t:Scientific">Scientific</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:Bool" class="def">Bool</a> !<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:Null" class="def">Null</a></td><td class="doc empty"> </td></tr></table></div><div class="subs instances"><p id="control.i:Value" class="caption collapser" onclick="toggleSection('i:Value')">Instances</p><div id="section.i:Value" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> <a href="Data-Yaml.html#t:Value">Value</a></span></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Data.html#t:Data">Data</a> <a href="Data-Yaml.html#t:Value">Value</a></span></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Read.html#t:Read">Read</a> <a href="Data-Yaml.html#t:Value">Value</a></span></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a> <a href="Data-Yaml.html#t:Value">Value</a></span></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:IsString">IsString</a> <a href="Data-Yaml.html#t:Value">Value</a></span></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/deepseq-1.4.1.1/Control-DeepSeq.html#t:NFData">NFData</a> <a href="Data-Yaml.html#t:Value">Value</a></span></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left">Hashable <a href="Data-Yaml.html#t:Value">Value</a></span></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Parser" class="def">Parser</a> a :: * -> *</p><div class="doc"><p>A JSON parser.</p></div><div class="subs instances"><p id="control.i:Parser" class="caption collapser" onclick="toggleSection('i:Parser')">Instances</p><div id="section.i:Parser" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Monad.html#t:Monad">Monad</a> <a href="Data-Yaml.html#t:Parser">Parser</a></span></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> <a href="Data-Yaml.html#t:Parser">Parser</a></span></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Applicative.html#t:Applicative">Applicative</a> <a href="Data-Yaml.html#t:Parser">Parser</a></span></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Applicative.html#t:Alternative">Alternative</a> <a href="Data-Yaml.html#t:Parser">Parser</a></span></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Monad.html#t:MonadPlus">MonadPlus</a> <a href="Data-Yaml.html#t:Parser">Parser</a></span></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Monoid.html#t:Monoid">Monoid</a> (<a href="Data-Yaml.html#t:Parser">Parser</a> a)</span></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:Object" class="def">Object</a> = <a href="file:///usr/share/doc/libghc-unordered-containers-doc/html/Data-HashMap-Strict.html#t:HashMap">HashMap</a> <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> <a href="Data-Yaml.html#t:Value">Value</a></p><div class="doc"><p>A JSON "object" (key/value map).</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:Array" class="def">Array</a> = <a href="file:///usr/share/doc/libghc-vector-doc/html/Data-Vector.html#t:Vector">Vector</a> <a href="Data-Yaml.html#t:Value">Value</a></p><div class="doc"><p>A JSON "array" (sequence).</p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:ParseException" class="def">ParseException</a> <a href="src/Data-Yaml-Internal.html#ParseException" class="link">Source</a></p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:NonScalarKey" class="def">NonScalarKey</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:UnknownAlias" class="def">UnknownAlias</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:_anchorName" class="def">_anchorName</a> :: <a href="Text-Libyaml.html#t:AnchorName">AnchorName</a></dt><dd class="doc empty"> </dd></dl><div class="clear"></div></div></td></tr><tr><td class="src"><a name="v:UnexpectedEvent" class="def">UnexpectedEvent</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:_received" class="def">_received</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="Text-Libyaml.html#t:Event">Event</a></dt><dd class="doc empty"> </dd><dt class="src"><a name="v:_expected" class="def">_expected</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="Text-Libyaml.html#t:Event">Event</a></dt><dd class="doc empty"> </dd></dl><div class="clear"></div></div></td></tr><tr><td class="src"><a name="v:InvalidYaml" class="def">InvalidYaml</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="Data-Yaml.html#t:YamlException">YamlException</a>)</td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:AesonException" class="def">AesonException</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:OtherParseException" class="def">OtherParseException</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Exception-Base.html#t:SomeException">SomeException</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:NonStringKeyAlias" class="def">NonStringKeyAlias</a> <a href="Text-Libyaml.html#t:AnchorName">AnchorName</a> <a href="Data-Yaml.html#t:Value">Value</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:CyclicIncludes" class="def">CyclicIncludes</a></td><td class="doc empty"> </td></tr></table></div><div class="subs instances"><p id="control.i:ParseException" class="caption collapser" onclick="toggleSection('i:ParseException')">Instances</p><div id="section.i:ParseException" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a> <a href="Data-Yaml.html#t:ParseException">ParseException</a></span> <a href="src/Data-Yaml-Internal.html#line-57" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Exception-Base.html#t:Exception">Exception</a> <a href="Data-Yaml.html#t:ParseException">ParseException</a></span> <a href="src/Data-Yaml-Internal.html#line-59" class="link">Source</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:prettyPrintParseException" class="def">prettyPrintParseException</a> :: <a href="Data-Yaml.html#t:ParseException">ParseException</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> <a href="src/Data-Yaml-Internal.html#prettyPrintParseException" class="link">Source</a></p><div class="doc"><p>Alternative to <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#v:show">show</a></code> to display a <code><a href="Data-Yaml.html#t:ParseException">ParseException</a></code> on the screen.
Instead of displaying the data constructors applied to their arguments,
a more textual output is returned. For example, instead of printing:</p><pre>InvalidYaml (Just (YamlParseException {yamlProblem = "did not find expected ',' or '}'", yamlContext = "while parsing a flow mapping", yamlProblemMark = YamlMark {yamlIndex = 42, yamlLine = 2, yamlColumn = 12}})))</pre><p>It looks more pleasant to print:</p><pre>YAML parse exception at line 2, column 12,
while parsing a flow mapping:
did not find expected ',' or '}'</pre><p>Since 0.8.11</p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:YamlException" class="def">YamlException</a> <a href="src/Text-Libyaml.html#YamlException" class="link">Source</a></p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:YamlException" class="def">YamlException</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:YamlParseException" class="def">YamlParseException</a></td><td class="doc"><p>problem, context, index, position line, position column</p></td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:yamlProblem" class="def">yamlProblem</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a></dt><dd class="doc empty"> </dd><dt class="src"><a name="v:yamlContext" class="def">yamlContext</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a></dt><dd class="doc empty"> </dd><dt class="src"><a name="v:yamlProblemMark" class="def">yamlProblemMark</a> :: <a href="Data-Yaml.html#t:YamlMark">YamlMark</a></dt><dd class="doc empty"> </dd></dl><div class="clear"></div></div></td></tr></table></div><div class="subs instances"><p id="control.i:YamlException" class="caption collapser" onclick="toggleSection('i:YamlException')">Instances</p><div id="section.i:YamlException" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a> <a href="Data-Yaml.html#t:YamlException">YamlException</a></span> <a href="src/Text-Libyaml.html#line-657" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Exception-Base.html#t:Exception">Exception</a> <a href="Data-Yaml.html#t:YamlException">YamlException</a></span> <a href="src/Text-Libyaml.html#line-658" class="link">Source</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:YamlMark" class="def">YamlMark</a> <a href="src/Text-Libyaml.html#YamlMark" class="link">Source</a></p><div class="doc"><p>The pointer position</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:YamlMark" class="def">YamlMark</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:yamlIndex" class="def">yamlIndex</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a></dt><dd class="doc empty"> </dd><dt class="src"><a name="v:yamlLine" class="def">yamlLine</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a></dt><dd class="doc empty"> </dd><dt class="src"><a name="v:yamlColumn" class="def">yamlColumn</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a></dt><dd class="doc empty"> </dd></dl><div class="clear"></div></div></td></tr></table></div><div class="subs instances"><p id="control.i:YamlMark" class="caption collapser" onclick="toggleSection('i:YamlMark')">Instances</p><div id="section.i:YamlMark" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a> <a href="Data-Yaml.html#t:YamlMark">YamlMark</a></span> <a href="src/Text-Libyaml.html#line-652" class="link">Source</a></td><td class="doc empty"> </td></tr></table></div></div></div><h1 id="g:2">Constructors and accessors</h1><div class="top"><p class="src"><a name="v:object" class="def">object</a> :: [<a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:Pair">Pair</a>] -> <a href="Data-Yaml.html#t:Value">Value</a></p><div class="doc"><p>Create a <code><a href="Data-Yaml.html#t:Value">Value</a></code> from a list of name/value <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:Pair">Pair</a></code>s. If duplicate
keys arise, earlier keys and their associated values win.</p></div></div><div class="top"><p class="src"><a name="v:array" class="def">array</a> :: [<a href="Data-Yaml.html#t:Value">Value</a>] -> <a href="Data-Yaml.html#t:Value">Value</a> <a href="src/Data-Yaml.html#array" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:.-61-" class="def">(.=)</a> :: <a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:KeyValue">KeyValue</a> kv => <span class="keyword">forall</span> v. <a href="Data-Yaml.html#t:ToJSON">ToJSON</a> v => <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> v -> kv</p></div><div class="top"><p class="src"><a name="v:.:" class="def">(.:)</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="Data-Yaml.html#t:Object">Object</a> -> <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> <a href="Data-Yaml.html#t:Parser">Parser</a> a</p><div class="doc"><p>Retrieve the value associated with the given key of an <code><a href="Data-Yaml.html#t:Object">Object</a></code>.
The result is <code>empty</code> if the key is not present or the value cannot
be converted to the desired type.</p><p>This accessor is appropriate if the key and value <em>must</em> be present
in an object for it to be valid. If the key and value are
optional, use '(.:?)' instead.</p></div></div><div class="top"><p class="src"><a name="v:.:-63-" class="def">(.:?)</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="Data-Yaml.html#t:Object">Object</a> -> <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> <a href="Data-Yaml.html#t:Parser">Parser</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> a)</p><div class="doc"><p>Retrieve the value associated with the given key of an <code><a href="Data-Yaml.html#t:Object">Object</a></code>.
The result is <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#v:Nothing">Nothing</a></code> if the key is not present, or <code>empty</code> if
the value cannot be converted to the desired type.</p><p>This accessor is most useful if the key and value can be absent
from an object without affecting its validity. If the key and
value are mandatory, use '(.:)' instead.</p></div></div><div class="top"><p class="src"><a name="v:.-33--61-" class="def">(.!=)</a> :: <a href="Data-Yaml.html#t:Parser">Parser</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> a -> <a href="Data-Yaml.html#t:Parser">Parser</a> a</p><div class="doc"><p>Helper for use in combination with <code><a href="Data-Yaml.html#v:.:-63-">.:?</a></code> to provide default
values for optional JSON object fields.</p><p>This combinator is most useful if the key and value can be absent
from an object without affecting its validity and we know a default
value to assign in that case. If the key and value are mandatory,
use '(.:)' instead.</p><p>Example usage:</p><pre> v1 <- o <code><a href="Data-Yaml.html#v:.:-63-">.:?</a></code> "opt_field_with_dfl" .!= "default_val"
v2 <- o <code><a href="Data-Yaml.html#v:.:">.:</a></code> "mandatory_field"
v3 <- o <code><a href="Data-Yaml.html#v:.:-63-">.:?</a></code> "opt_field2"
</pre></div></div><h1 id="g:3">Parsing</h1><div class="top"><p class="src"><a name="v:parseMonad" class="def">parseMonad</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Monad.html#t:Monad">Monad</a> m => (a -> <a href="Data-Yaml.html#t:Parser">Parser</a> b) -> a -> m b <a href="src/Data-Yaml.html#parseMonad" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:parseEither" class="def">parseEither</a> :: (a -> <a href="Data-Yaml.html#t:Parser">Parser</a> b) -> a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#t:Either">Either</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> b</p><div class="doc"><p>Run a <code><a href="Data-Yaml.html#t:Parser">Parser</a></code> with an <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#t:Either">Either</a></code> result type. If the parse fails,
the <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#v:Left">Left</a></code> payload will contain an error message.</p></div></div><div class="top"><p class="src"><a name="v:parseMaybe" class="def">parseMaybe</a> :: (a -> <a href="Data-Yaml.html#t:Parser">Parser</a> b) -> a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> b</p><div class="doc"><p>Run a <code><a href="Data-Yaml.html#t:Parser">Parser</a></code> with a <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a></code> result type.</p></div></div><h1 id="g:4">Classes</h1><div class="top"><p class="src"><span class="keyword">class</span> <a name="t:ToJSON" class="def">ToJSON</a> a <span class="keyword">where</span></p><div class="doc"><p>A type that can be converted to JSON.</p><p>An example type and instance:</p><pre>-- Allow ourselves to write <code><a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></code> literals.
{-# LANGUAGE OverloadedStrings #-}
data Coord = Coord { x :: Double, y :: Double }
instance ToJSON Coord where
toJSON (Coord x y) = <code><a href="Data-Yaml.html#v:object">object</a></code> ["x" <code><a href="Data-Yaml.html#v:.-61-">.=</a></code> x, "y" <code><a href="Data-Yaml.html#v:.-61-">.=</a></code> y]
toEncoding (Coord x y) = <code>pairs</code> ("x" <code><a href="Data-Yaml.html#v:.-61-">.=</a></code> x <code><></code> "y" <code><a href="Data-Yaml.html#v:.-61-">.=</a></code> y)
</pre><p>Instead of manually writing your <code><a href="Data-Yaml.html#t:ToJSON">ToJSON</a></code> instance, there are two options
to do it automatically:</p><ul><li><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-TH.html">Data.Aeson.TH</a> provides Template Haskell functions which will derive an
instance at compile time. The generated instance is optimized for your type
so will probably be more efficient than the following two options:</li><li>The compiler can provide a default generic implementation for
<code><a href="Data-Yaml.html#v:toJSON">toJSON</a></code>.</li></ul><p>To use the second, simply add a <code>deriving <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/GHC-Generics.html#t:Generic">Generic</a></code></code> clause to your
datatype and declare a <code><a href="Data-Yaml.html#t:ToJSON">ToJSON</a></code> instance for your datatype without giving
definitions for <code><a href="Data-Yaml.html#v:toJSON">toJSON</a></code> or <code><a href="Data-Yaml.html#v:toEncoding">toEncoding</a></code>.</p><p>For example, the previous example can be simplified to a more
minimal instance:</p><pre>{-# LANGUAGE DeriveGeneric #-}
import <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/GHC-Generics.html">GHC.Generics</a>
data Coord = Coord { x :: Double, y :: Double } deriving <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/GHC-Generics.html#t:Generic">Generic</a></code>
instance ToJSON Coord where
toEncoding = <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:genericToEncoding">genericToEncoding</a></code> <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:defaultOptions">defaultOptions</a></code>
</pre><p>Why do we provide an implementation for <code><a href="Data-Yaml.html#v:toEncoding">toEncoding</a></code> here? The
<code><a href="Data-Yaml.html#v:toEncoding">toEncoding</a></code> function is a relatively new addition to this class.
To allow users of older versions of this library to upgrade without
having to edit all of their instances or encounter surprising
incompatibilities, the default implementation of <code><a href="Data-Yaml.html#v:toEncoding">toEncoding</a></code> uses
<code><a href="Data-Yaml.html#v:toJSON">toJSON</a></code>. This produces correct results, but since it performs an
intermediate conversion to a <code><a href="Data-Yaml.html#t:Value">Value</a></code>, it will be less efficient
than directly emitting an <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:Encoding">Encoding</a></code>. Our one-liner definition of
<code><a href="Data-Yaml.html#v:toEncoding">toEncoding</a></code> above bypasses the intermediate <code><a href="Data-Yaml.html#t:Value">Value</a></code>.</p><p>If <code>DefaultSignatures</code> doesn't give exactly the results you want,
you can customize the generic encoding with only a tiny amount of
effort, using <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:genericToJSON">genericToJSON</a></code> and <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:genericToEncoding">genericToEncoding</a></code> with your
preferred <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:Options">Options</a></code>:</p><pre>instance ToJSON Coord where
toJSON = <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:genericToJSON">genericToJSON</a></code> <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:defaultOptions">defaultOptions</a></code>
toEncoding = <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:genericToEncoding">genericToEncoding</a></code> <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:defaultOptions">defaultOptions</a></code>
</pre></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="Data-Yaml.html#v:toJSON">toJSON</a></p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:toJSON" class="def">toJSON</a> :: a -> <a href="Data-Yaml.html#t:Value">Value</a></p><div class="doc"><p>Convert a Haskell value to a JSON-friendly intermediate type.</p></div><p class="src"><a name="v:toEncoding" class="def">toEncoding</a> :: a -> <a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:Encoding">Encoding</a></p><div class="doc"><p>Encode a Haskell value as JSON.</p><p>The default implementation of this method creates an
intermediate <code><a href="Data-Yaml.html#t:Value">Value</a></code> using <code><a href="Data-Yaml.html#v:toJSON">toJSON</a></code>. This provides
source-level compatibility for people upgrading from older
versions of this library, but obviously offers no performance
advantage.</p><p>To benefit from direct encoding, you <em>must</em> provide an
implementation for this method. The easiest way to do so is by
having your types implement <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/GHC-Generics.html#t:Generic">Generic</a></code> using the <code>DeriveGeneric</code>
extension, and then have GHC generate a method body as follows.</p><pre>instance ToJSON Coord where
toEncoding = <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:genericToEncoding">genericToEncoding</a></code> <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:defaultOptions">defaultOptions</a></code>
</pre></div></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a name="t:FromJSON" class="def">FromJSON</a> a <span class="keyword">where</span></p><div class="doc"><p>A type that can be converted from JSON, with the possibility of
failure.</p><p>In many cases, you can get the compiler to generate parsing code
for you (see below). To begin, let's cover writing an instance by
hand.</p><p>There are various reasons a conversion could fail. For example, an
<code><a href="Data-Yaml.html#t:Object">Object</a></code> could be missing a required key, an <code><a href="Data-Yaml.html#t:Array">Array</a></code> could be of
the wrong size, or a value could be of an incompatible type.</p><p>The basic ways to signal a failed conversion are as follows:</p><ul><li><code>empty</code> and <code>mzero</code> work, but are terse and uninformative</li><li><code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Monad.html#v:fail">fail</a></code> yields a custom error message</li><li><code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:typeMismatch">typeMismatch</a></code> produces an informative message for cases when the
value encountered is not of the expected type</li></ul><p>An example type and instance:</p><pre>-- Allow ourselves to write <code><a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></code> literals.
{-# LANGUAGE OverloadedStrings #-}
data Coord = Coord { x :: Double, y :: Double }
instance FromJSON Coord where
parseJSON (<code><a href="Data-Yaml.html#t:Object">Object</a></code> v) = Coord <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#v:-60--36--62-"><$></a></code>
v <code>.:</code> "x" <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Applicative.html#v:-60--42--62-"><*></a></code>
v <code>.:</code> "y"
-- We do not expect a non-<code><a href="Data-Yaml.html#t:Object">Object</a></code> value here.
-- We could use <code>mzero</code> to fail, but <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:typeMismatch">typeMismatch</a></code>
-- gives a much more informative error message.
parseJSON invalid = <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:typeMismatch">typeMismatch</a></code> "Coord" invalid
</pre><p>Instead of manually writing your <code><a href="Data-Yaml.html#t:FromJSON">FromJSON</a></code> instance, there are two options
to do it automatically:</p><ul><li><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-TH.html">Data.Aeson.TH</a> provides Template Haskell functions which will derive an
instance at compile time. The generated instance is optimized for your type
so will probably be more efficient than the following two options:</li><li>The compiler can provide a default generic implementation for
<code><a href="Data-Yaml.html#v:parseJSON">parseJSON</a></code>.</li></ul><p>To use the second, simply add a <code>deriving <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/GHC-Generics.html#t:Generic">Generic</a></code></code> clause to your
datatype and declare a <code><a href="Data-Yaml.html#t:FromJSON">FromJSON</a></code> instance for your datatype without giving
a definition for <code><a href="Data-Yaml.html#v:parseJSON">parseJSON</a></code>.</p><p>For example, the previous example can be simplified to just:</p><pre>{-# LANGUAGE DeriveGeneric #-}
import <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/GHC-Generics.html">GHC.Generics</a>
data Coord = Coord { x :: Double, y :: Double } deriving <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/GHC-Generics.html#t:Generic">Generic</a></code>
instance FromJSON Coord
</pre><p>If <code>DefaultSignatures</code> doesn't give exactly the results you want,
you can customize the generic decoding with only a tiny amount of
effort, using <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:genericParseJSON">genericParseJSON</a></code> with your preferred <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:Options">Options</a></code>:</p><pre>instance FromJSON Coord where
parseJSON = <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:genericParseJSON">genericParseJSON</a></code> <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#v:defaultOptions">defaultOptions</a></code>
</pre></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src">Nothing</p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:parseJSON" class="def">parseJSON</a> :: <a href="Data-Yaml.html#t:Value">Value</a> -> <a href="Data-Yaml.html#t:Parser">Parser</a> a</p></div></div><h1 id="g:5">Encoding/decoding</h1><div class="top"><p class="src"><a name="v:encode" class="def">encode</a> :: <a href="Data-Yaml.html#t:ToJSON">ToJSON</a> a => a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> <a href="src/Data-Yaml.html#encode" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:encodeFile" class="def">encodeFile</a> :: <a href="Data-Yaml.html#t:ToJSON">ToJSON</a> a => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:FilePath">FilePath</a> -> a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> () <a href="src/Data-Yaml.html#encodeFile" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:decode" class="def">decode</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> a <a href="src/Data-Yaml.html#decode" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:decodeFile" class="def">decodeFile</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> a) <a href="src/Data-Yaml.html#decodeFile" class="link">Source</a></p></div><h2 id="g:6">Better error information</h2><div class="top"><p class="src"><a name="v:decodeEither" class="def">decodeEither</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#t:Either">Either</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> a <a href="src/Data-Yaml.html#decodeEither" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:decodeEither-39-" class="def">decodeEither'</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#t:Either">Either</a> <a href="Data-Yaml.html#t:ParseException">ParseException</a> a <a href="src/Data-Yaml.html#decodeEither%27" class="link">Source</a></p><div class="doc"><p>More helpful version of <code><a href="Data-Yaml.html#v:decodeEither">decodeEither</a></code> which returns the <code><a href="Data-Yaml.html#t:YamlException">YamlException</a></code>.</p><p>Since 0.8.3</p></div></div><div class="top"><p class="src"><a name="v:decodeFileEither" class="def">decodeFileEither</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#t:Either">Either</a> <a href="Data-Yaml.html#t:ParseException">ParseException</a> a) <a href="src/Data-Yaml.html#decodeFileEither" class="link">Source</a></p><div class="doc"><p>A version of <code><a href="Data-Yaml.html#v:decodeFile">decodeFile</a></code> which should not throw runtime exceptions.</p><p>Since 0.8.4</p></div></div><h2 id="g:7">More control over decoding</h2><div class="top"><p class="src"><a name="v:decodeHelper" class="def">decodeHelper</a> :: <a href="Data-Yaml.html#t:FromJSON">FromJSON</a> a => <a href="file:///usr/share/doc/libghc-conduit-doc/html/Data-Conduit.html#t:Source">Source</a> Parse <a href="Text-Libyaml.html#t:Event">Event</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#t:Either">Either</a> <a href="Data-Yaml.html#t:ParseException">ParseException</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Either.html#t:Either">Either</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> a)) <a href="src/Data-Yaml-Internal.html#decodeHelper" class="link">Source</a></p></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.16.1</p></div></body></html>
|