JonathanReeve/jonreeve.com

get Atom feed working

Closed this issue · 4 comments

I started a branch for this which uses this Haskell module called Feed, but I can't quite get it to work, yet.

@srid, if you have any ideas for how best to do this with Rib, please let me know.

srid commented

@JonathanReeve What's the issue you are facing it? Is it anything to do with the Route GADT?

Kind of. I don't really understand how routes work yet, or GADTs. I feel like I'm super close to getting this, though.

The error I'm stuck at now is this:

src/Main.hs:97:25: error:
    • Couldn't match type ‘a’ with ‘Pandoc’
      ‘a’ is a rigid type variable bound by
        the type signature for:
          writeXmlRoute :: forall a. Route a -> a -> Action ()
        at src/Main.hs:96:7-48
      Expected type: a -> Action ()
        Actual type: Pandoc -> Action ()
    • In the expression: Rib.writeRoute r . renderFeed . toPosts r
      In an equation for ‘writeXmlRoute’:
          writeXmlRoute r = Rib.writeRoute r . renderFeed . toPosts r
      In the expression:
        do Rib.buildStaticFiles ["assets/**", "images/**", ....]
           let writeHtmlRoute :: Route a -> a -> Action ()
               writeHtmlRoute r = Rib.writeRoute r . renderText . renderPage r
               ....
           articles <- Rib.forEvery ["posts/*.md"] $ \ srcPath -> do ...
           writeHtmlRoute Route_CV articles
           ....
    • Relevant bindings include
        r :: Route a (bound at src/Main.hs:97:21)
        writeXmlRoute :: Route a -> a -> Action ()
          (bound at src/Main.hs:97:7)
   |
97 |       writeXmlRoute r = Rib.writeRoute r . RSS.renderFeed . toPosts r
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

srid commented

This is wrong:

toPosts :: Route a -> Pandoc -> [Post]

It should be "a" not "Pandoc". Basically, look at renderPage function, and how it does a case to unpack the GADT (thereby specializing a to Pandoc or whatever).

Thanks! I got it working, in the end.