Use Shakespeare-text and external file

Posted by Adam on Stack Overflow See other posts from Stack Overflow or by Adam
Published on 2012-10-09T01:00:32Z Indexed on 2012/10/09 3:37 UTC
Read the original article Hit count: 209

Filed under:
|
|
|

How can I convert the below example to use an external file instead of the embedded lazy text quasi quotes?

{-# LANGUAGE QuasiQuotes, OverloadedStrings #-}
import Text.Shakespeare.Text
import qualified Data.Text.Lazy.IO as TLIO
import Data.Text (Text)
import Control.Monad (forM_)

data Item = Item
    { itemName :: Text
    , itemQty :: Int
    }

items :: [Item]
items =
    [ Item "apples" 5
    , Item "bananas" 10
    ]

main :: IO ()
main = forM_ items $ \item -> TLIO.putStrLn
    [lt|You have #{show $ itemQty item} #{itemName item}.|]

This is from the yesod online book.

© Stack Overflow or respective owner

Related posts about haskell

Related posts about yesod