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

  • Home
  • SEARCH
  • 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 8235533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:50:36+00:00 2026-06-07T18:50:36+00:00

With multiple pattern-matching, different numbers of arguments are impossible, even with point-free! foo True

  • 0

With multiple pattern-matching, different numbers of arguments are impossible, even with point-free!

foo True b = b + 2
foo _ = id

doesn’t work for example. But

foo True = (+2)
foo _ = id

does. Sometimes we can use point-free only in one part of the function, so…

Why? Is it too hard for GHC? :'(

  • 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-07T18:50:37+00:00Added an answer on June 7, 2026 at 6:50 pm

    Why? Is it too hard for GHC?

    No. It is not at all too hard for GHC. Actually, this is the fault of the Haskell Report.

    See: Haskell Report 2010 > Declarations and Bindings > Function bindings

    A function binding binds a variable to a function value. The general form of a function binding for variable x is:

    x p11 … p1k match1
    …
    x pn1 … pnk matchn

    […blah blah…]

    Translation: The general binding form for functions is semantically equivalent to the equation (i.e. simple pattern binding):

    x = \ x1 … xk -> case (x1, …, xk) of

    (p11, …, p1k) match1
    …
    (pn1, …, pnk) matchn
    where the xi are new identifiers.

    (emphasis mine)

    While function definitions are semantically equivalent to a lambda & case expression, they are not necessarily compiled that way, as Mihai suggests.

    The thing is, the Haskell report defines function declarations such that they must have the same number of inputs on the left-hand side of the equation. This is made clear by the fact that k remains the same on both the 1st and the nth function declaration lines (and by implication, all lines in-between). This is the reason for the restriction; it has nothing to do with GHC’s implementation details.

    tl;dr

    The choice not to allow it is just a matter of style. – augustss

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

Sidebar

Related Questions

How do I perform action on all matching groups when the pattern matches multiple
I am trying to use sed for matching this pattern: it has multiple parts,
Is there a multiple instances pattern in F# somewhere? Consider that I'm working on
How do I match this pattern multiple times in a string for all of
Can someone explain how the mediator pattern works with multiple instances. My code in
Any suggestions on how I can cleanup the following code pattern that repeats multiple
Multiple NSURLConnections being started (in a single UIViewController) to gather different kinds of data.
I have multiple pages that have this pattern: <iframe frameborder =0 src=[someURL] width=100% height=900>
When I'm designing multiple views under the MVVM pattern, does each view get its
I'm looking for a pattern to organize header files for multiple platforms in C++.

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.