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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:33:04+00:00 2026-05-21T07:33:04+00:00

I recently generalized a type class away from a constraint MonadError GenError m to

  • 0

I recently generalized a type class away from a constraint MonadError GenError m to a more flexible constraint of MonadError e m, CanContainGenError e. This is useful for using the relevant monad transformer with a stack that already has an ErrorT SomeError m – I can just add GenError as an element of a new constructor in the SomeError data type.

I found myself surprised to be writing a custom CanContainGenError class hard-coded to GenError. Isn’t there a common ContainedType class or some such? (I almost called it “subtype”, heh)

Anything like the below CanContainType or ContainsType classes I just made up?

class CanContainType cont orig where
    toCont   :: orig -> cont
    fromCont :: cont -> Maybe orig

class ContainsType orig sub where
    toContainer :: orig -> cont
    fromContainer :: cont -> orig

Where an example instantiation is:

-- edit fixed example instance to reflect what I want, sorry for the misleading code
data IntOrFloatOrDouble= I Int | F Float | D Double
instance CanContainType IntOrFloatOrDouble Int where
    toCont   = I
    fromCont (I a) = Just a
    fromCont _ = Nothing

Now that I’ve typed this out I’m realizing there probably isn’t an established one because my requirements mandate MPTCs. Still, I’m interested in any thoughts.

  • 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-21T07:33:05+00:00Added an answer on May 21, 2026 at 7:33 am

    Sometimes things like this come up in EDSL construction, for lifting instances from Haskell to the EDSL. See e.g. http://www.galois.com/~dons/tmp/Type.hs

    data IntegralType a where
      TypeInt     :: IntegralDict Int     -> IntegralType Int
      TypeInt8    :: IntegralDict Int8    -> IntegralType Int8
      TypeInt16   :: IntegralDict Int16   -> IntegralType Int16
      TypeInt32   :: IntegralDict Int32   -> IntegralType Int32
      TypeInt64   :: IntegralDict Int64   -> IntegralType Int64
      ...
    

    There’s nothing standard, obviously.

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

Sidebar

Related Questions

Recently I ran into this error in my web application: java.lang.OutOfMemoryError: PermGen space It's
Recently Jeff has posted regarding his trouble with database deadlocks related to reading. Multiversion
Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
Recently, I started changing some of our applications to support MS SQL Server as
Recently, I've been dealing with an error with accessing MAPI via the .NET framework
Recently our site has been deluged with the resurgence of the Asprox botnet SQL
Recently I had to develop a SharePoint workflow, and I found the experience quite
Recently we got a new server at the office purely for testing purposes. It
Recently, I read an article entitled SATA vs. SCSI reliability . It mostly discusses
Recently a friend and I were talking about securing stored procedure code in a

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.