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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:52:34+00:00 2026-05-19T21:52:34+00:00

From prelude : foldl1 : it takes the first 2 items of the list

  • 0

From prelude:

foldl1: it takes the first 2 items of
the list and applies the function to
them, then feeds the function with
this result and the third argument and
so on.

Why is not possible to write something like this?

foldl1 (==) [6, 6, 6]
foldl1 (\x y -> x == y) [6, 6, 6]
  • 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-19T21:52:35+00:00Added an answer on May 19, 2026 at 9:52 pm

    EDIT: Antal points out that my reasoning was incorrect. Here is the relevant part of the comment that gives the real reasoning (I feel bad taking this verbatim, but this answer was accepted so I can’t delete it):

    The reason this doesn’t work is that the type of foldl1 is (a -> a -> a) -> [a] -> a, but the type of (==) is Num a => a -> a -> Bool. Since Bool isn’t a Num, (==) type doesn’t match a -> a -> a, and so the application of foldl1 is rejected. If it were accepted, you’d end up with a situation where you were trying to do True == 6, but the type system never gets you get that far in the first place.

    Original answer (latter reasoning incorrect):

    == will take two Ints and return a Bool. After the first iteration your example list becomes [True, 6]. It then tries to compare True to 6 which fails.

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

Sidebar

Related Questions

How to I define the equivalent of this function (taken from learnyouahaskell ) inside
Look at this output from ghci: Prelude> :t Data.Map.lookup Data.Map.lookup :: Ord k =>
From my website, I have a button which calls a method and then generates
From this context: import itertools lines = itertools.cycle(open('filename')) I'm wondering how I can implement
I have a class that looks like this: class Base < Library prelude some-value
This is toy-example.hs: {-# LANGUAGE ImpredicativeTypes #-} import Control.Arrow data From = From (forall
In Haskell I can easily define a recursive function which takes a value and
I need help understanding this type signature which is from the Thrist package. import
Here's a short transcript from GHCi: Prelude> :t read read :: Read a =>
Most of this is straight from the hint example. What I'd like to do

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.