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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:25:32+00:00 2026-06-06T09:25:32+00:00

I have the following: type KEY = (IPv4, Integer) type TPSQ = TVar (PSQ.PSQ

  • 0

I have the following:

type KEY = (IPv4, Integer)
type TPSQ = TVar (PSQ.PSQ KEY POSIXTime)
type TMap a = TVar (Map.Map KEY [a])

data Qcfg a = Qcfg { qthresh :: Int, tdelay :: Rational, cwpsq :: TPSQ, cwmap :: TMap a
, cwchan :: TChan String }

getTMap = do
   c <- ask
   return (cwmap c)

and get an error concerning the Reader Monad:

No instance for (MonadReader (Qcfg a2) m2)
      arising from a use of `ask'
    Possible fix:
      add an instance declaration for (MonadReader (Qcfg a2) m2)
    In a stmt of a 'do' expression: c <- ask
    In the expression:
      do { c <- ask;
           return (cwmap c) }
    In an equation for `getTMap':
        getTMap
          = do { c <- ask;
                 return (cwmap c) }

I have not enough understanding about the Reader Monad yet to determine how to fix this best.

[Edit]
Adding a type signature works for the parts that involve the type variable but creates an error for all the rest. E.g.

getTMap :: Reader (Qcfg a) (TMap a)
getTMap = do
   c <- ask
   return (cwmap c)

getTPsq :: Reader (Qcfg a) TPSQ
getTPsq = do
   c <- ask
   return (cwpsq c)
...
let q = getTPsq 
 qT <- atomically $ readTVar q

Results in

   Couldn't match expected type `TVar a0'
                with actual type `ReaderT
                                    (Qcfg a1) Data.Functor.Identity.Identity TPSQ'
    Expected type: TVar a0
      Actual type: Reader (Qcfg a1) TPSQ
    In the first argument of `readTVar', namely `q'
    In the second argument of `($)', namely `readTVar q'
  • 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-06T09:25:33+00:00Added an answer on June 6, 2026 at 9:25 am

    You just need to provide a type signature:

    getTMap :: Reader (Qcfg a) (TMap a)
    getTMap = do
      c <- ask
      return (cwmap c)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have declared the following type KEY = (IPv4, Integer) type TPSQ = TVar
I have following type of data ntrt = paste (EL, 1:4, sep= ) repl
I have following string. DATE: 12242010Key Type: Nod32 Anti-Vir (30d trial) Key: a5B2s-sH12B-hgtY3-io87N-srg98-KLMNO I
Let's say I have the following type type Key = String type Score =
I have following database schema for tabel tblpers Field Type Null Key Default Extra
I have a Map whose keys are of generic type Key<T> , and values
When using ASP.net webforms my usual solution would have following type of setup -
I have the following type of object : [RateInfo] => stdClass Object ( [@rateChange]
I have the following type in wsdl (it is generated by third party tool):
I have the following simple type: module Structures type Point2D<'T> (x : 'T, y

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.