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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:33:15+00:00 2026-05-27T11:33:15+00:00

when I type :t map length . sum into GHCi, it says that the

  • 0

when I type

:t map length . sum

into GHCi, it says that the type would be:

map length . sum :: Num [[a]] => [[[a]]] -> [Int]

However, if I create a file type-test.hs containing

x :: Num [[a]] => [[[a]]] -> [Int]
x = map length . sum

both ghc and ghci complain:

type-test.hs:1:1:
    Non type-variable argument in the constraint: Num [[a]]
    (Use -XFlexibleContexts to permit this)
    In the type signature for `x': x :: Num [[a]] => [[[a]]] -> [Int]

Why does ghci allow me to infer the type for this (using :t), when FlexibleContexts are not enabled?

  • 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-27T11:33:15+00:00Added an answer on May 27, 2026 at 11:33 am

    (This doesn’t answer your original question, but solves the problem with the code instead)

    These errors hint at that your code as written probably isn’t what you meant. This code:

    map length . sum
    

    means “Take my list of numbers, and sum it, then compute the length of each element(??) of the resulting number.” That makes no sense.

    You probably meant:

    sum . map length
    

    which means “Take my list of lists, compute the length of every element, and sum the lengths.”

    What the error message itself means is that since sum returns a number, aka the type of sum is Num n => [n] -> n, and you then try to use map length on that, which has type Num m => [[a]] -> [m], the compiler tries to say that n == [[a]] to make the types match, and everything goes downhill from there.

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

Sidebar

Related Questions

I have a simple requirement, i need a map of type . however i
I want to have a map that has a homogeneous key type but heterogeneous
I have a Map that uses a Set for the key type, like this:
I would like to import .csv .txt .xml and fixed length files into a
Give I have a 3D map of type whose the length and width are
I'm using a HeaderColumnNameMappingStrategy to map a csv file with a header into a
I have two maps of type Map<Long, Integer>, one named oldValues representing the old
I usually type my map declarations but was doing some maint and found one
I have an enum type on my Java model which I'd like to map
I am trying to assign a custom type as a key for std::map .

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.