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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:55:47+00:00 2026-06-15T17:55:47+00:00

I prefer to stick as closely as possible to the functional paradigm, squeezing as

  • 0

I prefer to stick as closely as possible to the functional paradigm, squeezing as close as I can get to the purely functional when my brain is up for the challenge. I use F# when possible. Usually, I’m stuck with either VB.NET or C# (or VBA, when I’m really unlucky). So my languages allow me to stray quite far from the functional approach.

Historically I’ve ignored logging and communicating with the user until I’ve got a result–just let the user wait. Now I’m trying to implement logging and/or updates of status bars. It’s easy, because my languages allow me to write to standard output whenever I want. But from a purely functional stand-point, how does one go about leaking information about what’s going on inside one’s function to the outside world? Is logging or communicating with the user during computation simply contrary to the purely functional approach?

I’m sure in Haskell one would use a Monad. What about when using other languages?

Thanks.

  • 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-15T17:55:48+00:00Added an answer on June 15, 2026 at 5:55 pm

    Let’s have a look at Haskell’s monadic solution. The idea behind logging is that our computations have an additional method that writes a message somewhere “out”. There are many ways how to represent such computations, but one of the most general is to make a monad:

    class (Monad m) => MonadWriter w m | m -> w where
        tell   :: w -> m ()
    

    Type w represents the messages and function tell is what “sends” a message into a monadic (effect-full) computation.

    Notes:

    • Haskell’s MonadWriter is actually richer, it contains functions that allow to examine and modify w, but let’s keep that aside for now.
    • The | m -> w part isn’t really important for the explanation, it just means that w is fixed for a given m.

    The most often used implementation is Writer, which is basically just a pair. One element of it is the result of a computation and the other element is a sequence of written messages. (Actually it’s not really a sequence, it’s more general – a monoid, which defines operations for combining multiple messages into one.) You can examine Haskell’s solution by looking at the Writer module. However it’s written more generally, using WriterT monad transformer, so if you’re not a monad fan, it can be quite hard to read. The same thing can be done in other functional languages as well, for example see this example in Scala.

    But there are other possible, more side-effect oriented (still functional) implementations of the above type class. We can define tell to emit messages to some outside sink, like to stdout, to a file, etc. For example:

    {-# LANGUAGE FunctionalDependencies, TypeSynonymInstances, FlexibleInstances #-}
    
    instance MonadWriter String IO where
        tell = putStrLn
    

    Here we say that IO can be used as a logging facility that writes Strings into stdout. (This is just a simplified example, a full implementation would probably have a monad transformer that would add tell functionality to any IO-based monad.)

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

Sidebar

Related Questions

I'm using Hibernate 3.6 but would prefer to stick to JPA annotations if possible.
Usually I prefer to write my own solutions for trivial problems because generally plugins
Possible Duplicate: Prefer composition over inheritance? I wonder, why (or in which cases) should
I prefer to use long identifiers to keep my code semantically clear, but in
I prefer to have the exception handling logic further up in the call stack,
I prefer for the solution file to be in the same folder as the
I prefer using Notepad++ for developing, How do I execute the files in Python
i prefer jquery. let's say i have a string with , adam, lisa, john,
// I prefer to perform forward declaration on myclass, as I do not //
What should I prefer when updating the database? What are the pros & cons

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.