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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:18:24+00:00 2026-05-29T12:18:24+00:00

I do not understand the difference between the three syntaxes: where a = f

  • 0

I do not understand the difference between the three syntaxes:

  • where a = f (b)
  • do a <- f (b)
  • do let a = f (b)

I do understand somehow though that a <- f(b) is different from the other two, in most cases where I tried all three worked. Also I read somewhere on the net that per block you should try to get along with one let binding only in order to be “idiomatic”. But I never seem to manage.

How do I decide what to use?

  • 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-29T12:18:25+00:00Added an answer on May 29, 2026 at 12:18 pm

    let foo = bar in ... simply defines foo to be the exact same thing as bar within the context of ...; you could simply use textual substitution to replace all uses of foo in ... with (bar) and get the exact same result.

    where clauses are similar to let...in expressions, but go at the end of a function clause, instead of being an expression. For instance,

    foo x
        | p1 = ... y ...
        | p2 = ... y ...
      where
        y = ...
    

    There is no way to rewrite this with let...in without changing the guards into if...then...elses. Often, where clauses are used over let...in clauses purely for reasons of style.

    The bind operator is something different entirely. It’s used in do notation to “extract” a value from a monadic computation. That is, if foo has the type m a, then after x <- foo, x has the type a. All the other “binding” forms just define names, but <- is used for binding a computation’s result to a name from within a monad. <- can only be used inside a do block, so it’s exclusively used to build up a larger computation in the same monad as the action you’re binding the result of.

    let foo = bar in do notation is just a convenience; you can rewrite:

    do let foo = bar
       ...
    

    as

    let foo = bar
    in do ...
    

    but that gets messy when you have a lot of such bindings, as the do blocks get nested deeper and deeper.

    I don’t know what the advice you mentioned is talking about; you can define multiple variables in a let...in block just fine, and

    let foo = ...
        bar ...
    in ...
    

    is more idiomatic than

    let foo = ...
    in let bar = ...
       in ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I do not quite understand the difference between a C# reference and a pointer.
I'm not able to understand the difference between Thread vs ThreadPool. Consider i've to
I'm not sure I understand if there is a difference between a finite state
Something I'm not to clear about, I understand there are differences between C# and
There is a difference in the description on MSDN, however, I do not understand
It took me quite some time to understand the difference between an rvalue and
This is a follow up question from Grammar: difference between a top down and
From my research, i understand there are three ways to place an svg file
I was trying to understand the difference between closures and function pointers, and I
I'm trying to understand the difference between Ruby threads pre-1.9 and 1.9 (in the

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.