1
我一直在下面this tutorial學習耶索德,並正嘗試運行這個簡單的形式:當我runhaskell forms.hs
,我得到這個錯誤可保存格式類型耶索德
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
import Control.Applicative((<$>),(<*>))
import Yesod
data App = App
mkYesod "App" [parseRoutes|
/accum Accum GET
|]
instance Yesod App
instance RenderMessage App FormMessage where
renderMessage _ _ = defaultFormMessage
data Info = Info
{ deposit :: Double
, rate :: Double
, years :: Double
}
aform :: AForm App App Info
aform = Info
<$> areq doubleField "Deposit" Nothing
<*> areq doubleField "Rate" Nothing
<*> areq doubleField "Years" Nothing
accum x = deposit x * (1 + rate x * years x)
mform = renderTable aform
getAccum :: Handler RepHtml
getAccum = do
((result, widget), enc) <- runFormGet mform
case result of
FormSuccess info -> defaultLayout [whamlet|<p> #{show (accum info)} |]
_ -> defaultLayout [whamlet|
<form method=get [email protected]{Accum} enctype=#{enc}>
<table>
^{widget}
<input type=submit>
|]
main = warpDebug 2012 App
:
forms.hs:27:10:
‘AForm’ is applied to too many type arguments
In the type signature for ‘aform’: aform :: AForm App App Info
後用類型簽名的一些變化來破壞我,我不斷收到錯誤。該ghci的:info AForm
讀取
Prelude Yesod> :info AForm
type role AForm nominal nominal
newtype AForm (m :: * -> *) a
但更改aform :: AForm (App -> App) Info
給了我這個錯誤:
forms.hs:27:17:
The first argument of ‘AForm’ should have kind ‘* -> *’,
but ‘App -> App’ has kind ‘*’
上的任何想法如何解決這個問題?