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 7794235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:43:20+00:00 2026-06-01T22:43:20+00:00

I know it is verbose but that is how I am learning the syntax.

  • 0

I know it is verbose but that is how I am learning the syntax. With this line at

(abCombo’ a 2 lst) … I want to return the ‘list’ and/or print the list but I am having trouble extracting the list with this return type, ‘ Writer [String] [Int]’.

-- Loop through several integer values
-- and calculate the power of a^b, append to list
abCombo' :: Int -> Int -> [Int] -> Writer [String] [Int]
abCombo' a b lst
    | b == maxB = do
        tell [ "  ... x-Done(1): a^b = " ++ show (a^b) ++ " // " ++ show lst  ]
        return ((a^b):lst)
    | otherwise = do
        tell [ "  ... x-Processing: a^b = " ++ show (a^b) ++ " // " ++ show lst ]
        abCombo' a (b+1) ((a^b):lst)

-- Loop through several integer values
-- and calculate the power of a^b, append to list
abCombo :: Int -> [Int] -> Writer [String] [Int]
abCombo a lst
    | a == maxA = do              
        tell [ "- Done(2): a=" ++ show a ]
        abCombo' a 2 lst
    | otherwise = do
        (abCombo' a 2 lst) <<<<<<<<<<<<<<<<<<<<<< line of interest, here
        tell ["- Processing: a=" ++ show a]
        abCombo (a + 1) lst 

…

That is the current code above, I want to change it to:

abCombo :: Int -> [Int] -> Writer [String] [Int]
abCombo a lst
    | a == maxA = do              
        tell [ "- Done(2): a=" ++ show a ]
        abCombo' a 2 lst
    | otherwise = do
        let res = (abCombo' a 2 lst) <<<<<<<<<<<<<<<<<<<<<< line of interest, here            
        tell ["- Processing: a=" ++ show a]
        abCombo (a + 1) (flatten snd res)
  • 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-01T22:43:22+00:00Added an answer on June 1, 2026 at 10:43 pm

    To bind the result of an action in a do-block you need to use <- instead of let.

    res <- abCombo' a 2 lst      -- res :: [Int]
    

    This is because with let, you’re just putting a name on the action itself.

    let res = abCombo' a 2 lst   -- res :: Writer [String] [Int]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this is quite subjective, but is it something that I have
I'm want to use a URLLoader in one line, but I know Internet Explorer
Know this might be rather basic, but I been trying to figure out how
I know this is kind of easy question but i cant seem to find
I know that != is not equal, but what does it mean when you
First thing you should know is that this worked on Wednesday of last week
I know this has been asked a lot of times in StackOverflow already, but
I asked this on ServerFault, but didn't get any reply's, I know it's command
So this happens to me regularly, where i have gems that are installed but
Does someone know how to write a program in C with the verbose option

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.