Skip to content

Instantly share code, notes, and snippets.

@deckool
Created July 28, 2016 13:01
Show Gist options
  • Save deckool/5a5a253e83fc153ba3019e6fe78fd18e to your computer and use it in GitHub Desktop.
Save deckool/5a5a253e83fc153ba3019e6fe78fd18e to your computer and use it in GitHub Desktop.
haskell with rich blaze-html parsing for RDF
{-# LANGUAGE OverloadedStrings #-}
import Prelude
import qualified Prelude as P
import Data.Monoid (mempty)
import Text.Blaze.Html5
import qualified Text.Blaze.Html5 as H
import Text.Blaze.Html5.Attributes
import qualified Text.Blaze.Html5.Attributes as A
itemPage :: Html
itemPage = do
body ! vocab "http://schema.org/" ! resource "http://example.com/explosive-tennis-balls" ! typeof "ItemPage" $ do
link ! property "copyrightHolder publisher" ! href "#Organization"
main $ article ! resource "#Product" ! property "mainEntity" ! typeof "Product" $ do
h1 ! property "name" $ a ! property "url" ! href "http://example.com/explosive-tennis-balls" $ "Explosive tennis balls"
img ! property "image" ! alt "Explosive tennis balls" ! A.title "" ! src "http://example.com/explosive-tennis-balls.jpg"
p ! resource "#Offer" ! property "offers" ! typeof "Offer" $ do
meta ! property "priceCurrency" ! content "USD"
meta ! property "price" ! content "1000.00"
link ! property "availability" ! href "InStock"
link ! property "itemOffered" ! href "#Product"
link ! property "businessFunction" ! href "http://purl.org/goodrelations/v1#Sell"
link ! rev "makesOffer" ! href "#Organization"
"$29.99 - In stock"
p ! property "description" $ do
"Tickle your friends!"
br
"Surprise your opponent!"
footer $ p ! resource "#Organization" ! typeof "Organization" $ do
"©"
H.span ! resource "#CopyrightYear" ! typeof "rdfa:Pattern" $ "2015"
"-"
H.span ! property "name" $ "Acme Inc"
link ! property "logo" ! href "http://example.com/acme-inc-logo.jpg"
link ! property "url" ! href "http://example.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment