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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:47:48+00:00 2026-05-28T22:47:48+00:00

I am currently learning Haskell. I am trying to write a function which given

  • 0

I am currently learning Haskell. I am trying to write a function which given two list of n distinct elements returns true if one is a permutation of the other. I am doing this as an exercise.

I first wrote it as :

isPermut :: (Eq a)=>[a]->[a]->Bool
isPermut u v = foldl (\acc x -> acc && (elem x u)) True v

This seems to work. I now try to rewrite it without lambda expression. So I try :

isPermut :: (Eq a)=>[a]->[a]->Bool
isPermut u v = foldl (&& (flip $ elem u)) True v

This gives me a compile error :

Couldn't match expected type `b0 -> Bool' with actual type `Bool'
Expected type: Bool -> b0 -> Bool
  Actual type: Bool -> Bool
In the first argument of `foldl', namely `(&& (flip $ elem u))'
In the expression: foldl (&& (flip $ elem u)) True v

What does this error mean? What is the correct way to write the function without lambda?
Thanks.

  • 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-28T22:47:49+00:00Added an answer on May 28, 2026 at 10:47 pm

    Folds have to take a function of two arguments. You gave a function of one argument since (&& whatever) is the same as \ x -> x && whatever.

    To not use a lambda here, you need some way to compose &&, a two-argument function, with (`elem` u), a one-argument function. (Note that (`elem` u) is the same as (flip elem) u or \ x -> elem x u.)

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

Sidebar

Related Questions

I'm currently learning Haskell, Which language (F# or Haskell) do you prefer for programming
I'm currently learning libgmp and to that end I'm writing a small program which
Currently learning Spring MVC with Spring 3, I'm trying to find the correct way
im currently learning jQuery and have ran into a problem. I am trying to
I had some experience in Haskell and currently learning Scala. Am wondering whether there
I am currently learning PHP and I want to start incorporating Facebook basic elements
I'm currently learning OCaml, and it's giving me some problems. I'm trying to implement
I'm learning haskell. Currently working through 99 questions , a little bit stuck on
I currently learning about scrum and want to learn from experienced professionals in the
im currently learning python (in the very begining), so I still have some doubts

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.