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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:26:03+00:00 2026-05-27T20:26:03+00:00

In Haskell, I often write expressions with $’s. I find it quite natural and

  • 0

In Haskell, I often write expressions with $’s. I find it quite natural and readable, but I sometimes read it is bad form and do not understand why it should be.

  • 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-27T20:26:04+00:00Added an answer on May 27, 2026 at 8:26 pm

    The following are all good form:

    foo = bar . baz . quux
    foo x = bar . baz . quux $ x
    foo x = (bar . baz . quux) x
    foo x = bar (baz (quux x))
    

    I’ve put them in rough order of my preference, though as always taste varies, and context may demand a different choice. I’ve also occasionally seen

    foo = bar
        . baz
        . quux
    

    when each of the bar, baz, and quux subexpressions are long. The following is bad form:

    foo x = bar $ baz $ quux $ x
    

    There are two reasons this is less preferable. First, fewer subexpressions can be copied and pasted into an auxiliary definition during refactoring; with all ($) operators, only subexpressions that include the x argument are valid refactorings, whereas with (.) and ($) operators even subexpressions like bar . baz or baz . quux can be pulled out into a separate definition.

    The second reason to prefer (.) is in anticipation of a possible change to the fixity of ($); currently, ($) is infixr, meaning it associates to the right, like so:

    foo x = bar $ (baz $ (quux $ x))
    

    However, ($) would be useful in more expressions if it were infixl; for example, something like

    foo h = f (g x) (h y)
    foo h = f $ g x $ h y
    foo h = (f $ g x) $ h y
    

    …which currently cannot be expressed without parentheses. The “bad form” example, when parsed with an infixl application, would be

    foo x = ((bar $ baz) $ quux) $ x
    

    which means something significantly different. So, future-proof your code by avoiding this form.

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

Sidebar

Related Questions

I often read that lazy is not the same as non-strict but I find
I often find this pattern in Haskell code: options :: MVar OptionRecord options =
I know newtype is more often compared to data in Haskell, but I'm posing
In Haskell function type ( -> ) is given, it's not an algebraic data
Learn You a Haskell has an example about functors. I can read LYAH, and
Haskell's Network.Browser module seems to not do any compression. How can I configure it
I often find myself wanting to insert regular functions into a binded sequence. Like
Haskell newbie wants to know why the first 3 were ok but the 4th
While using applicative functors in Haskell I've often run into situations where I end
I often see the usage and explanation of Haskell's parallel strategies connected to pure

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.