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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:21:27+00:00 2026-05-21T17:21:27+00:00

I just began to learn Haskell and am having trouble with adjusting to the

  • 0

I just began to learn Haskell and am having trouble with adjusting to the language, for example on the implementation of map more specifically when trying to do similar operations as in the example bellow;

rotate :: Dimensions ->  imgBlock -> [(imgBlock,Int)]
rotate d ((p, pix), s, t) 
  = zip [((p, f pix), s, t) | f <- transformate (fst d)] [0..7]

makeAllRotations :: Dimensions -> [imgBlock] -> [(imgBlock,Int)]
makeAllRotations d ib = map concat (rotate d ib)              //Error points Here

Where

type imgBlock = (Block, Int, Int)
type Block = (Pnt, Pxl)
type Dimensions = (Int, Int)

And this is one of the errors i get

asdf.hs:73:30:
    Couldn't match expected type `(imgBlock, Int)'
                with actual type `[a0]'
    Expected type: [[a0]] -> (imgBlock, Int)
      Actual type: [[a0]] -> [a0]
    In the first argument of `map', namely `concat'
    In the expression: map concat (rotate d ib)

I find myself quite frustrated trying to adjust to this new programming ‘paradigm’ where most of the things I managed to do are through trial and error. I am obviously not understanding map correctly, although i have read the documentation on this website, but all the examples are shown in console like map (2+) [1,2,3] not so much when using them in functions.

Could I get some pointers on where am i going wrong on my map implementation. Thks

  • 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-05-21T17:21:27+00:00Added an answer on May 21, 2026 at 5:21 pm

    The best way to find the problem is to look at the types:

    rotate :: Dimensions -> ImgBlock -> [(ImgBlock,Int)]
    makeAllRotations :: Dimensions -> [ImgBlock] -> [(ImgBlock,Int)]
    map :: (a -> b) -> [a] -> [b]
    concat :: [[a]] -> [a]
    

    The map function is trying to call concat on each of the (ImgBlock,Int) pairs in the list returned by rotate. But concat expects to get a nested list as its argument. But the big thing that helped me figure out how to fix it was looking at rotate d ib. The second argument to rotate is ImgBlock, but in that context ib :: [ImgBlock]. You can’t pass in a list when a single item is expected. But that’s what the map function is for. It allows you to take a function that accepts a single item (‘a’ in the type signature above) and use that function when you have [a]. I suspect what you want is something like this:

    makeAllRotations d ib = concat $ map (rotate d) ib
    

    Because rotate returns a list, map (rotate d) ib returns a list of lists, which fits perfectly as the first argument to the concat function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just began recently to learn Haskell, more specifically on the topics of
I just began reading more about Markov Chain Generators today, and am really intrigued
I've recently caught the FP bug (trying to learn Haskell), and I've been really
I just started to learn latex and now I'm trying to create a table.
I have just begun to learn JS. I am trying to change the value
I'm always trying to learn more about the languages I use (different styles, frameworks,
Please note: I'm just trying to learn. Please do not yell at me for
I just began having problems with Indy. For some weird reason, even this very
Hey, I just began to learn ruby/rails. At the moment, I try to do
I recently started using the Yii framework trying to learn a little bit more

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.