Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8895583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:49:05+00:00 2026-06-14T23:49:05+00:00

Let message/en.msg file like: Category1: some text 1 Category2: some text 2 … CategoryN:

  • 0

Let message/en.msg file like:

Category1: some text 1
Category2: some text 2
    ...
CategoryN: some text N

And let next valid code:

getHomeR :: Handler RepHtml
getHomeR = do

    (msg :: AppMessage -> Text) <- getMessageRender

    let list = T.concat $ map msg [MsgCategory1, MsgCategory7]

    defaultLayout $ do
        $(widgetFile "homepage") -- <p>List: #{list}

then, list contains MsgCategory1 and MsgCategory7 translations.

I want to do some like:

    let list = T.concat $ map msg [MsgCategory1 .. MsgCategory7]

but AppMessage is not Enum derived.

My another one alternative is not valid too (is not Read derived too)

    let list = T.concat $ map (\n -> msg $ read "MsgCategory" ++ show n) [1 .. 7]

In general, how to cast “in real time” AppMessage elements?

Thank you very much!

(I love Yesod! 🙂 )

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:49:06+00:00Added an answer on June 14, 2026 at 11:49 pm

    One way I found is here

    deriving instance Enum AppMessage
    deriving instance Eq AppMessage
    deriving instance Read AppMessage
    deriving instance Show AppMessage
    ...
    

    (require -XStandaloneDeriving)

    Explained:

    Change on Foundation.hs:

    -- Set up i18n messages. See the message folder.
    mkMessage "App" "messages" "en"
    
    -- Require extension: StandaloneDeriving
    deriving instance Enum AppMessage
    

    On site.cabal:

    extensions: TemplateHaskell
                QuasiQuotes
                OverloadedStrings
                NoImplicitPrelude
                CPP
                MultiParamTypeClasses
                TypeFamilies
                GADTs
                GeneralizedNewtypeDeriving
                FlexibleContexts
                EmptyDataDecls
                NoMonomorphismRestriction
                StandaloneDeriving
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I saw code like this: template<class T> T* safe_ptr_cast(Message& msg) { assert(msg.header()->size() ==
I have a queue of text messages in Redis. Let's say a message in
$.each(json.data,function(i,fb){ //some code here... if (msg.length > 150) { msg = msg.substr(0,200)+...; } //more
Here I want to use System IPCs methods like <sys/msg.h> /* SysV message queues
Let's say I want to send a message from one client to another. How
Let a binary string composed of messages separated by one null byte: <message><null><message><null> ...
How to know is the message sender is my network provider let's say the
I have Ubuntu Linux. I found one command will let me download unread message
Let's have an example like below: package xliiv.sandbox; import android.app.Activity; import android.os.Bundle; import android.util.Log;
When running the following code open System open Microsoft.FSharp.Control type Message(id, contents) = static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.