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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:12:13+00:00 2026-06-13T11:12:13+00:00

Every other monad comes with a transformer version, and from what I know the

  • 0

Every other monad comes with a transformer version, and from what I know the idea of a transformer is a generic extension of monads. Following how the other transformers are build, IOT would be something like

newtype IOT m a = IOT { runIOT :: m (IO a) }

for which I could make up useful applications on the spot: IOT Maybe can either do an IO action or nothing, IOT [] can build a list that can later be sequenced.

So why is there no IO transformer in Haskell?

(Notes: I’ve seen this post on Haskell Cafe, but can’t make much sense of it. Also, the Hackage page for the ST transformer mentions a possibly related issue in its description, but doesn’t offer any details.)

  • 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-13T11:12:14+00:00Added an answer on June 13, 2026 at 11:12 am

    Consider the specific example of IOT Maybe. How would you write a Monad instance for that? You could start with something like this:

    instance Monad (IOT Maybe) where
        return x = IOT (Just (return x))
        IOT Nothing >>= _ = IOT Nothing
        IOT (Just m) >>= k = IOT $ error "what now?"
          where m' = liftM (runIOT . k) m
    

    Now you have m' :: IO (Maybe (IO b)), but you need something of type Maybe (IO b), where–most importantly–the choice between Just and Nothing should be determined by m'. How would that be implemented?

    The answer, of course, is that it wouldn’t, because it can’t. Nor can you justify an unsafePerformIO in there, hidden behind a pure interface, because fundamentally you’re asking for a pure value–the choice of Maybe constructor–to depend on the result of something in IO. Nnnnnope, not gonna happen.

    The situation is even worse in the general case, because an arbitrary (universally quantified) Monad is even more impossible to unwrap than IO is.


    Incidentally, the ST transformer you mention is implemented differently from your suggested IOT. It uses the internal implementation of ST as a State-like monad using magic pixie dust special primitives provided by the compiler, and defines a StateT-like transformer based on that. IO is implemented internally as an even more magical ST, and so a hypothetical IOT could be defined in a similar way.

    Not that this really changes anything, other than possibly giving you better control over the relative ordering of impure side effects caused by IOT.

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

Sidebar

Related Questions

My iPhone project fails to build every other time and gives me the following
From the Xcode Docs : Syntax highlighting, code completion, and every other index-driven feature
This question results from hours of googling highstocks, zoom, extremes, ranges, and every other
Given what I know of every other type of static feature of programming––I would
Does the following cron expression mean execute every other Sunday? 0 0 3 ?
I would like to delete every other line from a Vim buffer, starting with
I have a matrix in MATLAB from which I want to sample every other
I've read every other thread on this and have tried everything but the Build
Every other class in Java inherits from the Object class. Is it possible to
I have a base controller from which every other controller inherits. I would like

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.