Skip to content

Instantly share code, notes, and snippets.

@notcome
Created March 2, 2015 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notcome/c64b095f10d44440c755 to your computer and use it in GitHub Desktop.
Save notcome/c64b095f10d44440c755 to your computer and use it in GitHub Desktop.
Human readable Haskell representation for "Quick Quote"
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE UnicodeSyntax #-}
import Prelude hiding (putStrLn)
import Data.Text.Lazy.IO (putStrLn)
import Control.Monad.Writer
-- Monoid Instance --
import Text.Blaze.Internal ()
import qualified Text.Blaze.Html5 as H
import qualified Text.Blaze.Html5.Attributes as A
import Text.Blaze.Html.Renderer.Text
writeHtml = renderHtml . execWriter
par = tell . H.p
infixl 3 <*
infixl 5 <<*
infixr 4 *>>
infixr 2 *>
a <* b = a <> H.span b
a <<* b = a <> H.span b
(*>) = (<>)
(*>>) = (<>)
main = do
let result = writeHtml $ do
par $ "thread"<*"线程"*>"是……"
par $ "thread"<*"线程"<<*"或"<>H.span "duang"*>>"线程"*>"是……"
putStrLn result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment