I'm trying to go through the ihp blog tutorial, but I'm not sure how to resolve this error. I'm new to haskell. I've tried asking chat gpt, but no luck so far.
Do I need to initialize an empty comment when I create a post? I assume so because NewView is defined with that field.
error
Web/Controller/Posts.hs:47:37
* Fields of `NewView' not initialised:
comment :: Comment
* In the first argument of `render', namely `NewView {..}'
In the expression: render NewView {..}
In a case alternative: Left post -> render NewView {..}
|
47 | Left post -> render NewView { .. }
| ^^^^^^^^^^^^^^
source code
-- Web/Controller/Posts.hs
action CreatePostAction = do
let post = newRecord @Post
post
|> buildPost
|> ifValid \case
Left post -> render NewView { .. }
Right post -> do
post <- post |> createRecord
setSuccessMessage "Post created"
redirectTo PostsAction
-- ./Web/View/Comments/New.hs
data NewView = NewView
{ comment :: Comment
, post :: Post
}