Hi I am a beginner in Haskell and Yesod and I need help with this problem.
These are my entities:
Location
name Text sqltype=varchar(255)
address AddressId Maybe sqltype=varchar(255)
UniqueLocationName name
deriving Show Typeable
Manifestation
name Text sqltype=varchar(255)
description Text Maybe sqltype=varchar(255)
category Category Maybe
startDateTime UTCTime sqltype=DateTime
location LocationId Maybe sqltype=varchar(255)
UniqueManName name
deriving Show Typeable
This is my handler that calls the man-details template:
getManDetailsR :: ManifestationId -> Handler Html
getManDetailsR mid = do
(_, user) <- requireAuthPair
md <- runDB $ get404 mid -- type is Manifestation
defaultLayout $ do
setTitle "Manifestation details"
$(widgetFile "man-details")
And part of the man-details hamlet file where I want to display information about the event:
<div class="row">
<div class="col-md-5">
<div class="project-info-box mt-0">
<h2>#{manifestationName md}
<p class="mb-0">#{fromJust(manifestationDescription md)}
<div class="project-info-box">
<p><b>Start :</b>{show $ manifestationStartDateTime md}
<p><b>Location :</b>#{locationName (manifestationLocation md)}
In this case error is : Couldn't match expected type ‘Location’ with actual type ‘Maybe (Key Location)’
Then I try like this :
$maybe l <- manifestationLocation md
<p><b>Location :</b>{locationName l}
And error is : Couldn't match expected type ‘Location’ with actual type ‘Key Location’
I apologize for the huge question, but I don't know how to get out of this, ie how to get only the value out of this pair (Key Location)?
Any advice and help is welcome,
Thanks.
l
contains theKey
of aLocation
, not theLocation
itself, for that you will need another query. – Willem Van Onsem