Для альфа-формы я получил некоторые ошибки компиляции:Йесод ошибки при компиляции
1. По умолчанию значение Int: сообщение
data Person = Person
{ name :: Text
, age :: Maybe Int
}
deriving Show
formPerson :: AForm Handler Person
formPerson = Person
<$> areq textField "Person Name" Nothing
<*> aopt intField "Person Age" (Just 25)
Ошибка:
No instance for (Num (Maybe Int)) arising from the literal ‘25’
In the first argument of ‘Just’, namely ‘25’
In the third argument of ‘aopt’, namely ‘(Just 25)’
In the second argument of ‘(<*>)’, namely
‘aopt intField "Person Age" (Just 25)’
2. Ошибка в шаблоне: getPersonR :: Handler Html
getPersonR = do
let myAge = 25::Int
defaultLayout $ do
$(widgetFile "persone")
И шаблона:
<span>My age: #{myAge}
Конец ошибки:
Not in scope: ‘myAge’
In the splice: $(widgetFile "persone")
3. Ошибка в результате:
postPersonR :: Handler Html
postPersonR = do
((result, formWidget), formEnctype) <- runFormPost formPerson
let title = "Success!"::Html
case result of
FormSuccess person ->
defaultLayout $ do
setTitle title
$(widgetFile "personresult")
_ ->
defaultLayout $ do
$(widgetFile "person")
и Шаблон:
<strong>Your name: #{name person}
И ошибка:
Couldn't match expected type ‘Person -> a0’
with actual type ‘blaze-markup-0.6.1.1:Text.Blaze.Internal.MarkupM
()’
The function ‘name’ is applied to one argument,
but its type ‘Html’ has none
In the first argument of ‘toHtml’, namely ‘name person’
In the first argument of ‘asWidgetT GHC.Base.. toWidget’, namely
‘toHtml (name person)’
Как исправить проблемы?