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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:55:16+00:00 2026-06-08T11:55:16+00:00

According to the introduction about ReaderT , I can only find: ReaderT Env IO

  • 0

According to the introduction about ReaderT , I can only find:

ReaderT Env IO String

And it means

...is a computation which involves reading values from some environment 
of type Env (the semantics of Reader, the base monad) and performing some 
IO in order to give a value of type String.

So the order of execution will become

1. ( Already has ) some environment values          -- ReaderT Env
2. Do `IO` accroding to these pre-existing values   -- IO a
3. Use the `IO a` values to do more computations    -- IO b...z

This will requests our program has some pre-existing values as the environment, but I thought most of program need to load these environment values. Such like the database URL, debugging switcher or anything else.

Thus, we have an inverse order of execution, and which is illegal according to the Monad stack:

1. Do some `IO` to load environment settings        -- IO a first !!
2. Do more `IO` according to these settings         -- fill the env and do IO  

The monad stack will become:

IOT Env ReaderT Env

This is illegal because the IO monad can’t be the base monad in monad stack. So, is there a proper way to initialize my program with external setting files ?

PS1. I noticed that the xmonad compile it’s settings as a part of program. I’m still not sure whether this is the only way to “load” settings…

  • 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-08T11:55:18+00:00Added an answer on June 8, 2026 at 11:55 am

    First, the order of monads in the monad stack doesn’t have anything to do with the order of actions that you’re going to perform.

    Second, you probably don’t even need a stack here.

    A typical program that deals with configuration is structured in the following way:

    data Config = ...
    
    readConfig :: IO Config
    readConfig = do
        text <- readFile "~/.config"
        let config = ... -- do some parsing here
        return config
    
    
    meat :: Reader Config Answer
    meat = do
        -- invoke some operations, which get config automatically through the
        -- monad
    
    main = do
        config <- readConfig
        let answer = runReader meat config
        print answer
    

    You need a monad stack only if meat itself needs to perform some IO (apart from reading the config). In that case, you’d have

    meat :: ReaderT Config IO Answer
    meat = ...
    
    main = do
        config <- readConfig
        answer <- runReaderT meat config
        print answer
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading about String algorithms in Introduction to Algorithms by Cormen etc Following
According to this post in Recursive Descent vs. LALR , any LALR(k) can be
According to Introduction to Neural Networks with Java By Jeff Heaton, the input to
According to what I've heard, integer values that are not the processor's word size
According To reflector , ExpandoObject Does implemenet IDictionary<string, object> How ever I have this
According to the W3C Recommendation for the CSS background shorthand , the values are
I can't get natbib to display the full author name. Instead, I only get
According to my class notes, you can allocate an array in C++ like int
i am trying out the async-feature in grails. According to http://grails.org/doc/2.0.0.M1/guide/introduction.html#webFeatures it is now
According to the tutorial I am reading, the program below displays Hello Ima Reader.

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.