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 ‘*’
上的任何想法如何解决这个问题?