<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Working with feeds – Haskell – Aelve Guide</title><id>https://guide.aelve.com/haskell/feed/category/gr6kte15</id><updated>2016-03-18T19:29:37Z</updated><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/feed/category/gr6kte15"/><entry><id>l8p4vyrc</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">atom-basic</title><updated>2016-03-18T19:29:37Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;atom-basic&lt;/span&gt;

  
  (&lt;a href=&#34;https://hackage.haskell.org/package/atom-basic&#34;&gt;Hackage&lt;/a&gt;)
&lt;/h1&gt;&lt;h2&gt;Pros&lt;/h2&gt;&lt;ul&gt;&lt;/ul&gt;&lt;h2&gt;Cons&lt;/h2&gt;&lt;ul&gt;&lt;/ul&gt;</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/working-with-feeds-gr6kte15#item-l8p4vyrc"/></entry><entry><id>x7ekxq7y</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">yesod-newsfeed</title><updated>2016-03-18T19:29:28Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;yesod-newsfeed&lt;/span&gt;

  
  (&lt;a href=&#34;https://hackage.haskell.org/package/yesod-newsfeed&#34;&gt;Hackage&lt;/a&gt;)
&lt;/h1&gt;&lt;h2&gt;Pros&lt;/h2&gt;&lt;ul&gt;&lt;/ul&gt;&lt;h2&gt;Cons&lt;/h2&gt;&lt;ul&gt;&lt;p&gt;&lt;li&gt;Not a standalone library – can only be used with Yesod.&lt;/li&gt;&lt;/p&gt;&lt;/ul&gt;</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/working-with-feeds-gr6kte15#item-x7ekxq7y"/></entry><entry><id>dnt8urny</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">rss</title><updated>2016-03-18T19:28:47Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;rss&lt;/span&gt;

  
  (&lt;a href=&#34;https://hackage.haskell.org/package/rss&#34;&gt;Hackage&lt;/a&gt;)
&lt;/h1&gt;&lt;h2&gt;Pros&lt;/h2&gt;&lt;ul&gt;&lt;/ul&gt;&lt;h2&gt;Cons&lt;/h2&gt;&lt;ul&gt;&lt;p&gt;&lt;li&gt;Can&#39;t generate Atom feeds.&lt;/li&gt;&lt;/p&gt;&lt;p&gt;&lt;li&gt;Uses &lt;code&gt;String&lt;/code&gt; instead of &lt;code&gt;Text&lt;/code&gt;.&lt;/li&gt;&lt;/p&gt;&lt;/ul&gt;</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/working-with-feeds-gr6kte15#item-dnt8urny"/></entry><entry><id>m9jtvxuv</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">feed</title><updated>2016-03-18T19:28:35Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;feed&lt;/span&gt;

  
  (&lt;a href=&#34;https://hackage.haskell.org/package/feed&#34;&gt;Hackage&lt;/a&gt;)
&lt;/h1&gt;&lt;p&gt;A big and fairly complete (but messy) library for generating, parsing, and validating Atom/RSS feeds.&lt;/p&gt;
&lt;h2&gt;Pros&lt;/h2&gt;&lt;ul&gt;&lt;p&gt;&lt;li&gt;The only library here that can parse feeds in addition to generating them.&lt;/li&gt;&lt;/p&gt;&lt;p&gt;&lt;li&gt;Supports the most number of formats (Atom, RSS 2.x, and even old RSS 1.0).&lt;/li&gt;&lt;/p&gt;&lt;/ul&gt;&lt;h2&gt;Cons&lt;/h2&gt;&lt;ul&gt;&lt;p&gt;&lt;li&gt;Uses &lt;code&gt;String&lt;/code&gt; instead of &lt;code&gt;Text&lt;/code&gt;.&lt;/li&gt;&lt;/p&gt;&lt;p&gt;&lt;li&gt;Kinda complicated (and you would have to take several looks at others&#39; feeds and at the documentation for Atom/RSS formats, since the library itself doesn&#39;t have much documentation).&lt;/li&gt;&lt;/p&gt;&lt;/ul&gt;&lt;h2&gt;Notes&lt;/h2&gt;&lt;h1&gt;&lt;span id=&#34;item-notes-m9jtvxuv-links&#34;&gt;&lt;/span&gt;Links&lt;/h1&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/bergmark/feed/blob/master/tests/Example/CreateAtom.hs&#34;&gt;An example of creating an Atom feed&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;&lt;span id=&#34;item-notes-m9jtvxuv-imports&#34;&gt;&lt;/span&gt;Imports&lt;/h1&gt;&lt;p&gt;For Atom feeds:&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;kw&#34;&gt;import qualified&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Text.Feed.Types&lt;/span&gt; &lt;span class=&#34;kw&#34;&gt;as&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Feed&lt;/span&gt;
&lt;span class=&#34;kw&#34;&gt;import qualified&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Text.Feed.Util&lt;/span&gt;  &lt;span class=&#34;kw&#34;&gt;as&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Feed&lt;/span&gt;

&lt;span class=&#34;kw&#34;&gt;import qualified&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Text.Atom.Feed&lt;/span&gt;        &lt;span class=&#34;kw&#34;&gt;as&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Atom&lt;/span&gt;
&lt;span class=&#34;kw&#34;&gt;import qualified&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Text.Atom.Feed.Export&lt;/span&gt; &lt;span class=&#34;kw&#34;&gt;as&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Atom&lt;/span&gt;

&lt;span class=&#34;co&#34;&gt;-- from the “xml” package&lt;/span&gt;
&lt;span class=&#34;kw&#34;&gt;import qualified&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Text.XML.Light.Output&lt;/span&gt; &lt;span class=&#34;kw&#34;&gt;as&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;XML&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h1&gt;&lt;span id=&#34;item-notes-m9jtvxuv-creating-an-atom-feed&#34;&gt;&lt;/span&gt;Creating an Atom feed&lt;/h1&gt;&lt;p&gt;There are several types that you would need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://hackage.haskell.org/package/feed/docs/Text-Atom-Feed.html#t:Feed&#34;&gt;&lt;code&gt;Feed&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://hackage.haskell.org/package/feed/docs/Text-Atom-Feed.html#t:Entry&#34;&gt;&lt;code&gt;Entry&lt;/code&gt;&lt;/a&gt; (feed entry)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://hackage.haskell.org/package/feed/docs/Text-Atom-Feed.html#t:EntryContent&#34;&gt;&lt;code&gt;EntryContent&lt;/code&gt;&lt;/a&gt; (can be e.g. &lt;code&gt;TextContent&lt;/code&gt;, &lt;code&gt;HTMLContent&lt;/code&gt;, or a few others)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://hackage.haskell.org/package/feed/docs/Text-Atom-Feed.html#t:TextContent&#34;&gt;&lt;code&gt;TextContent&lt;/code&gt;&lt;/a&gt; is unrelated to &lt;code&gt;EntryContent&lt;/code&gt;, and can be a &lt;code&gt;TextString&lt;/code&gt; or a &lt;code&gt;HTMLString&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://hackage.haskell.org/package/feed/docs/Text-Atom-Feed.html#t:Person&#34;&gt;&lt;code&gt;Person&lt;/code&gt;&lt;/a&gt; (author of an entry)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://hackage.haskell.org/package/feed/docs/Text-Atom-Feed.html#t:Link&#34;&gt;&lt;code&gt;Link&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each of these (apart from &lt;code&gt;EntryContent&lt;/code&gt; and &lt;code&gt;TextContent&lt;/code&gt;) is a record with lots of fields. You would almost never need all of those fields, so there are some helper functions available that make initialising them easier. For instance, to create a &lt;code&gt;Link&lt;/code&gt;, use &lt;code&gt;nullLink&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;-- URI = String&lt;/span&gt;
&lt;span class=&#34;ot&#34;&gt;nullLink ::&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;URI&lt;/span&gt; &lt;span class=&#34;ot&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Link&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And then you can customise some of the fields:&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;nullLink &lt;span class=&#34;st&#34;&gt;&amp;quot;http://foo.bar&amp;quot;&lt;/span&gt; {
  linkTitle &lt;span class=&#34;fu&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Just&lt;/span&gt; &lt;span class=&#34;st&#34;&gt;&amp;quot;Foo Bar&amp;quot;&lt;/span&gt; }&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Same with &lt;code&gt;nullEntry&lt;/code&gt; and &lt;code&gt;nullFeed&lt;/code&gt;; a complete example can be found &lt;a href=&#34;https://github.com/bergmark/feed/blob/master/tests/Example/CreateAtom.hs&#34;&gt;here&lt;/a&gt;. Note that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The example uses &lt;code&gt;String&lt;/code&gt;s as dates. If you want to convert &lt;code&gt;UTCTime&lt;/code&gt; to the string format expected by the library, use &lt;code&gt;toFeedDateStringUTC AtomKind&lt;/code&gt; (from &lt;code&gt;Text.Feed.Util&lt;/code&gt; and &lt;code&gt;Text.Feed.Types&lt;/code&gt; respectively).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The newest entry should be the 1st in the list.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The feed ID (i.e. the 1st parameter to &lt;code&gt;nullFeed&lt;/code&gt;) doesn&#39;t have to be a link – for instance, for &lt;a href=&#34;https://github.com/bergmark/feed/commits/master.atom&#34;&gt;Github feeds&lt;/a&gt; it&#39;s something like&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;tag:github.com,2008:/bergmark/feed/commits/master&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Entry IDs, contrary to what the example says, don&#39;t have to be links either.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/working-with-feeds-gr6kte15#item-m9jtvxuv"/></entry></feed>