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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:37:54+00:00 2026-05-17T14:37:54+00:00

Since side-effects break referential transparency, don’t they go against the point of functional languages?

  • 0

Since side-effects break referential transparency, don’t they go against the point of functional languages?

  • 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-17T14:37:54+00:00Added an answer on May 17, 2026 at 2:37 pm

    There are two techniques that are used by purely functional programming languages to model side effects:

    1) A world type that represents external state, where each value of that type is guaranteed by the type system to be used only once.

    In a language that uses this approach the function print and read might have the types (string, world) -> world and world -> (string, world) respectively.

    They might be used like this:

    let main w =
      let w1 = print ("What's your name?", w) in
      let (name, w2) = read w1 in
      let w3 = print ("Your name is " ^ name, w2) in
      w3
    

    But not like this:

    let main w =
      let w1 = print ("What's your name?", w) in
      let (name, w2) = read w in
      let w3 = print ("Your name is " ^ name, w2) in
      w3
    

    (because w is used twice)

    All built-in functions with side-effects would take and return a world value. Since all functions with side-effects are either built-ins or call other functions with side-effects, this means that all functions with side-effects need to take and return a world.

    This way it is not possible to call a function with side-effects twice with the same arguments and referential transparency is not violated.

    2) An IO monad where all operations with side effects have to be executed inside that monad.

    With this approach all operations with side effects would have type io something. For example print would be a function with type string -> io unit and read would have type io string.

    The only way to access the value of performing operation would be to use the “monadic bind” operation (called >>= in haskell for example) with the IO operation as one argument and a function describing what to do with the result as the other operand.

    The example from above would look like this with monadic IO:

    let main =
      (print "What's your name?") >>=
      (lambda () -> read >>=
      (lambda name -> print ("Your name is " ^ name)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a very small side project, I need VS professional. Since the target is
Since TCP header is a relatively large overhead, why don't we compress it in
Any code can provide side effects. Most of the time, side effects can be
Generally, a get request is not meant to have any side-effects. However many sites
Function calculate_attribute does not return a value; it only works through side effects. Often
Since the support for BO and Crystal pretty much stinks when it comes to
Since I installed IE8 (Win XP) Visual Studio 2008 Pro stopped deebugging javascript. When
Since version 1.5 Subversion supports to have a local caching-proxy for the main Master-repository.
since IE won't render XHTML as XHTML, but treat it as HTML instead, when
Since Eclipse 3.5 there seems to be no option to have drop a plugin

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.