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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:43:39+00:00 2026-06-08T07:43:39+00:00

Just learning about State monad from this excellent tutorial . However, when I tried

  • 0

Just learning about State monad from this excellent tutorial. However, when I tried to explain it to a non-programmer they had a question that stumped me.

If the purpose of the State is to simulate mutable memory, why is the function that state monad stores is of the type:

s -> (a, s)

and not simply:

s -> s

In other words, what is the need for the “intermediate” value? For example, couldn’t we, in the cases where we need it, simulate it by simply defining a state as a tuple of (state, value)?

I’m sure I confused something, any help is appreciated.

  • 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-08T07:43:40+00:00Added an answer on June 8, 2026 at 7:43 am

    To draw a parallel with an imperative language like C, s -> s corresponds to a function with the return type void, which is invoked purely for side effects (such as mutating the memory). It is isomorphic to State s ().

    And indeed, it is possible to write C functions which communicate only through global variables. But, as in C, it is often convenient to return values from functions. That’s what a is for.

    Of course it’s possible that for your particular problem s -> s is a better choice. Although it’s not a Monad, it is a Monoid (when wrapped in Endo). So you can construct such functions using <> and mempty, which correspond to >>= and return of Monad.

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

Sidebar

Related Questions

Just learning about with statements especially from this article question is, can I pass
Hey guys, just learning about composition of classes and ran into this error. Gradebook.h
I am just learning about LINQ to XML in all its glory and frailty,
I'm just learning about python. I'm fairly new. I have the following code that
I want to understand the actual theory behind types rather than just learning about
I just started learning about CSRF. As per OWASP CSRF Article CSRF is an
I've just started learning about Gimp scripting using Python, and was wondering, how do
I'm enrolled in Coursera ML class and I just started learning about neural networks.
I am in an introductory java course and we just started learning about inheritance.
A bit of a newbie question for iOS, just started learning about Core Graphics

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.