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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:13:14+00:00 2026-06-06T20:13:14+00:00

In this tutorial I’ve found the following snippet: deposit :: (Num a) => a

  • 0

In this tutorial I’ve found the following snippet:

deposit :: (Num a) => a -> a -> Maybe a
deposit value account = Just (account + value)

withdraw :: (Num a,Ord a) => a -> a -> Maybe a
withdraw value account = if (account < value) 
                         then Nothing 
                         else Just (account - value)

eligible :: (Num a, Ord a) => a -> Maybe Bool
eligible account =
  deposit 100 account >>=
  withdraw 200 >>=
  deposit 100  >>=
  withdraw 300 >>=
  deposit 1000 >>
  return True

main = do
  print $ eligible 300 -- Just True
  print $ eligible 299 -- Nothing

I can’t figure out how the >>= function is supposed to work. At first it takes a Maybe a value as its first parameter: deposit 100 account >>=

Afterwards, however it seems to take a -> Maybe a as its first parameter: withdraw 200 >>= How could this be approved by the compiler? Shouldn’t >>= always take Maybe a as its first parameter?

A possible solution would be if the >>= function’s precedence would work in the following way: ((a >>= b) >>= c) >>= d

But as far as I know, it is the opposite: a >>= (b >>= (c >>= d))

  • 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-06T20:13:16+00:00Added an answer on June 6, 2026 at 8:13 pm

    as far as I know, it is the opposite: a >>= (b >>= (c >>= d))

    nope.

    GHCi> :i >>=
    class Monad m where
      (>>=) :: m a -> (a -> m b) -> m b
      ...
        -- Defined in `GHC.Base'
    infixl 1 >>=
    

    infixl means that it’s left-associative, so a >>= b >>= c >>= d ≡ ((a >>= b) >>= c) >>= d.

    It wouldn’t actually make much sense if it were infixr, would it? >>= always returns a monad, and its RHS takes a function. So in any chain of monadic expressions linked with >>= would be in the (->) r monad, which is hardly the most useful one.

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

Sidebar

Related Questions

In this tutorial , I found the following commands. ICACLS %SystemDrive%\Windows\System32\inetsrv\config /Grant Network Service:R
Following this tutorial and running into trouble. [TestMethod] [ExpectedException(typeof(Exception))] public void VerifyPropertyNameMethod_NonExistentPropertyString_ThrowsException() { var
Following this tutorial (http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/handling-concurrency-with-the-entity-framework-in-an-asp-net-mvc-application), I learned how to save data and do concurrency checks
I was following this tutorial . I need to use a php file's ouput
I'm running through this tutorial found here: http://vb.net-informations.com/crystal-report/vb.net_crystal_report_from_multiple_tables.htm which teaches how to pass a
In this tutorial , where are the following values coming from? password ( OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
I'm following this tutorial: ExpandableListView But in my device (Samsung Galaxy S i9000) the
I found this tutorial about how to build a simple voting system. I already
I'm following this tutorial http://ruby.railstutorial.org/ The tutorial seems to be using Rails 3.0. I
Following this tutorial: http://www.vogella.de/articles/AndroidServices/article.html#receiver I created my own project. Manifest: <?xml version=1.0 encoding=utf-8?> <manifest

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.