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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:46:55+00:00 2026-05-28T13:46:55+00:00

I have a monad transformer stack of the form: newtype T m a =

  • 0

I have a monad transformer stack of the form:

newtype T m a = T { unT :: StateT State (SqlPersist m) a }
   deriving (Monad, MonadState State)

And want to use the persistent insert and lookup calls, so I need to make a PersistBackend instance for T. However, a phantom type encodes the specific backend into the Key return type – this causes some extra headaches. To solve the phantom type issue, my instance has the form:

instance (Monad m, MonadIO m, MonadBaseControl IO m) => PersistBackend T m where
   insert = T . lift . liftM (Key . unKey) . insert
   ... and about a dozen such methods ...

Am I blindly overlooking an easier way? A way other than calling the function by manually lifting: insertT = T . lift . insert

  • 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-28T13:46:56+00:00Added an answer on May 28, 2026 at 1:46 pm

    I have two different recommendations:

    1. Flip things around, and put the SqlPersist around your StateT instead of vice-versa.
    2. Create a module with lifted versions of the functions, similar to what MonadState does.

    I’d go for (1). If a lot of people are running into this, I suppose we could have a specialized package providing the lifted versions of all the functions.

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

Sidebar

Related Questions

I have a problem to which a stack of monad transformers (or even one
I have a set of Happstack.State MACID methods that I want to test using
If I have a stack of monads, say IO , State and Error ,
So I want to have a bunch of functions that receive a state and
I have the following monad transformer for dealing with errors in Haskell. instance (Monad
Consider the next example. I have a monad MyM that is just a StateT
Suppose I have a state monad such as: data Registers = Reg {...} data
Let me state up front that I have an infantile understanding of Monads. I
Is it possible to use type synonyms as arguments of monad transformers' type constructor?
I am stuck with following monad problem: Let's say I have a standard monad

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.