From b1a3b537119981d38a1356e708479d7ac12c11fe Mon Sep 17 00:00:00 2001 From: Luke Date: Wed, 13 Dec 2023 11:22:10 +0000 Subject: [PATCH] Simplify example usage for optionsFromList' --- yesod-form/Yesod/Form/Option.hs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/yesod-form/Yesod/Form/Option.hs b/yesod-form/Yesod/Form/Option.hs index 628c0a5b2..fcbd9dc0b 100644 --- a/yesod-form/Yesod/Form/Option.hs +++ b/yesod-form/Yesod/Form/Option.hs @@ -17,13 +17,6 @@ import Yesod.Form.Fields -- -- === __Example usage__ -- --- @messages/en.msg --- > MsgSalesTeam: Sales Team --- > MsgSalesHead: Head of Sales Team --- > MsgTechTeam: Tech Team --- > MsgTechHead: Head of Tech Team --- --- @example.hs -- > data UserRole = URSalesTeam | URSalesHead | URTechTeam | URTechHead -- > -- > instance PathPiece UserDepartment where @@ -44,11 +37,12 @@ import Yesod.Form.Fields -- > userRoleOptions = optionsFromList' userRoles toMsg -- > where -- > userRoles = [URSalesTeam, URSalesHead, URTechTeam, URTechHead] +-- > toMsg :: UserRole -> Text -- > toMsg = \case --- > URSalesTeam -> MsgSalesTeam --- > URSalesHead -> MsgSalesHead --- > URTechTeam -> MsgTechTeam --- > URTechHead -> MsgTechHead +-- > URSalesTeam -> "Sales Team" +-- > URSalesHead -> "Head of Sales Team" +-- > URTechTeam -> "Tech Team" +-- > URTechHead -> "Head of Tech Team" -- -- userRoleOptions, will produce an OptionList with the following attributes: -- @@ -63,6 +57,9 @@ import Yesod.Form.Fields -- > +----------------+----------------+--------------------+ -- > | URTechHead | tech-head | Head of Tech Team | -- > +----------------+----------------+--------------------+ +-- +-- Note that the type constraint allows localizable messages in place of toMsg (see +-- https://en.wikipedia.org/wiki/Yesod_(web_framework)#Localizable_messages). optionsFromList' :: MonadHandler m