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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:41:07+00:00 2026-05-13T05:41:07+00:00

I have been trying to wrap my head around functional programming for a while

  • 0

I have been trying to wrap my head around functional programming for a while now. I have looked up lambda calculus, LISP, OCaml, F# and even combinatorial logic but the main problem I have is this – how do you do things that require side effects like:

  • interacting with a user,
  • communicating with a remote service, or
  • handle simulating using random sampling

without violating the fundamental premise of pure functional programming which is, that for a given input the output is deterministic?

I hope I am making sense; if not I welcome any attempts to help me understand. Thanks in advance.

  • 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-13T05:41:07+00:00Added an answer on May 13, 2026 at 5:41 am

    Most real-world functional programming is not “pure” in most senses, so half of the answer to your question is “you do it by giving up on purity”. That said, there are alternatives.

    In the “purest” sense of pure, the entire program represents a single function of one or more arguments, returning a value. If you squint your eyes and wave your hands a bit, you can declare that all user input is part of the function’s “arguments” and that all output is part of the “return value” and then fudge things a bit so that it only does the actual I/O “on demand”.

    A similar perspective is to declare that the input to the function is “the entire state of the outside world” and that evaluating the function returns a new, modified “state of the world”. In that case, any function in the program that uses the world state is obviously freed from being “deterministic” since no two evaluations of the program will have exactly the same outside world.

    If you wanted to write an interactive program in the pure lambda calculus (or something equivalent, such as the esoteric language Lazy K), that’s conceptually how you’d do it.

    In more practical terms, the problem comes down to making sure that I/O occurs in the correct order when input is being used as an argument to a function. The general structure of the “pure” solution to this problem is function composition. For instance, say you have three functions that do I/O and you want to call them in a certain order. If you do something like RunThreeFunctions(f1, f2, f3) there’s nothing to determine the order they’ll be evaluated in. On the other hand, if you let each function take another function as an argument, you can chain them like this: f1( f2( f3())), in which case you know that f3 will be evaluated first because the evaluation of f2 depends on its value. [Edit: See also the comment below about lazy vs. eager evaluation. This is important, because lazy evaluation is actually quite common in very pure contexts; e.g., the standard implementation of recursion in the pure lambda calculus is nonterminating under eager evaluation.]

    Again, to write an interactive program in the lambda calculus, this is how you’d probably do it. If you wanted something actually usable for programming in, you’d probably want to combine the function composition part with the conceptual structure of functions taking and returning values representing the state of the world, and create some higher-order abstraction to handling pipelining the “world state” values between I/O functions, ideally also keeping the “world state” contained in order to enforce strict linearity–at which point you’ve all but reinvented Haskell’s IO Monad.

    Hopefully that didn’t just make you even more confused.

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

Sidebar

Related Questions

I have been trying to wrap my head around this for a while now
For sometime now, I have been trying to wrap my head around the reason
I have been trying to wrap my head around this FXCop violation DoNotDeclareReadOnlyMutableReferenceTypes MSDN:
I have been trying to wrap my head around this issue but I am
I have been trying to wrap my head around NSDate , NSCalendar , NSDateComponents
I have been trying to wrap my head around mvvm for the last week
I have been trying to get around this error for a day now and
I am trying to wrap my head around some WPF specific stuff, and have
I've been banging my head against a wall trying to wrap my head around
Ok, so I've been trying to wrap my head around recursion in Java and

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.