我是haskell的初学者,我正在尝试使用hamlet,但我没有得到正确的语法。当我使用此代码时:
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
module Handler.Index where
import Import
import Network.HTTP.Types.Status
import Database.Persist.Postgresql
getIndexR :: Handler Html
getIndexR = defaultLayout $ do
addStylesheet $ StaticR bootstrap_css
[hamlet|
$doctype 5
<html>
<head>
<body>
|]
[cassius|
.classe
background: red;
|]我得到了这个错误:
romefeller:~/workspace/yesodvazio (master) $ stack build && stack exec
aulahaskell
aulahaskell-0.0.0: build (lib + exe)
Preprocessing library aulahaskell-0.0.0...
[8 of 9] Compiling Handler.Index ( src/Handler/Index.hs, .stack-
work/dist/x86_64-linux/Cabal-1.24.2.0/build/Handler/Index.o )
/home/ubuntu/workspace/yesodvazio/src/Handler/Index.hs:18:17: error: parse
error on input ‘<’
-- While building package aulahaskell-0.0.0 using:
/home/ubuntu/.stack/setup-exe-cache/x86_64-linux/Cabal-
simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-
linux/Cabal-1.24.2.0 build lib:aulahaskell exe:aulahaskell --ghc-options " -
ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1我遗漏了什么?我需要导入任何库或其他东西吗?
发布于 2017-10-22 23:50:09
您需要启用:
{-# LANGUAGE QuasiQuotes #-}而不是TemplateHaskell或其他GHC尝试解析您的[hamlet|...|]子句,就像它是列表理解的开始一样,如下所示:
[ hamlet | hamlet <- ["alas", "poor", "yorick"] ]
^^^^^^^^^^ -- GHC thinks you're starting to write this
-- and can't parse the rest.( TemplateHaskell扩展只为它识别的特定准引号类型启用准引号语法,并尝试将其他所有内容解析为列表理解语法。)
https://stackoverflow.com/questions/46875832
复制相似问题