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

  • Home
  • SEARCH
  • 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 8941419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:17:50+00:00 2026-06-15T11:17:50+00:00

In the MonadTrans class: class MonadTrans t where — | Lift a computation from

  • 0

In the MonadTrans class:

class MonadTrans t where
    -- | Lift a computation from the argument monad to the constructed monad.
    lift :: Monad m => m a -> t m a

why isn’t t m constrained to be a Monad? i.e., why not:

{-# LANGUAGE MultiParamTypeClasses #-}
class Monad (t m) => MonadTrans t m where
  lift :: Monad m => m a -> t m a

If the answer is “because that’s just the way it is”, that’s fine — it’s just confusing for a n008.

  • 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-15T11:17:51+00:00Added an answer on June 15, 2026 at 11:17 am

    You suggested the following:

    class Monad (t m) => MonadTrans t m where
        lift :: Monad m => m a -> t m a
    

    …but does that really mean what you want? It seems you want to express something like “a type t may be an instance of MonadTrans if, for all m :: * -> * where m is an instance of Monad, t m is also an instance of Monad“.

    What the class definition above actually says is more like “types t and m may constitute an instance of MonadTrans if, for those specific types, t m is an instance of Monad“. Consider carefully the difference, and the implied potential for instances that may not be what you’d want.

    In the general case, every parameter of a type class is an independent “argument”, a fact which has been a bountiful source of both headaches and GHC extensions as people have attempted to use MPTCs.

    Which isn’t to say that such a definition couldn’t be used anyway–as you point out, the current definition is not ideal either. The age-old problem “Why Data.Set Is Not a Functor” is related, and such issues helped motivate the recent ConstraintKinds tomfoolery.

    The ultimate answer to “why not” here is almost certainly the one given by Daniel Fischer in the comments–because MonadTrans is pretty core functionality, it would be undesirable to make it depend on some terrifying cascade of increasingly arcane GHC extensions.

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

Sidebar

Related Questions

{-# LANGUAGE DeriveDataTypeable, OverloadedStrings, ScopedTypeVariables #-} module Db ( couchTest ) where import Control.Monad.IO.Class
I am experimenting with an mtl -style class that allows me to lift Pipe
I wrote a small script to extract data from Oracle using Takusen: {-# LANGUAGE
I am trying to build a MaybeT-Transformer Monad, based on the example in the
I'm experimenting with Trifecta for parsing a very simple functional language with Haskell-like layout
The docs for Control.Monad.Trans.Error provide this example of combining two monads: type ErrorWithIO e
I don't know why my code breaks. At first I thought it was because
So I'm writing a roguelike and I need to generate some dungeons randomly. I
I am using the Haskeline package and I want to get three strings in
I'm trying to work with Ubigraph in haskell, but I believe my problem is

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.