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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:35:08+00:00 2026-05-15T16:35:08+00:00

Is it possible to write something like: data SomeData = SomeValue | (Integral a)

  • 0

Is it possible to write something like:

data SomeData = SomeValue | (Integral a) => SomeConstructor a

And how exactly would one write this?

  • 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-15T16:35:08+00:00Added an answer on May 15, 2026 at 4:35 pm

    This is similar to Daniel Pratt’s answer, but the more typical approach is to leave off the type constraints on your data definition, like this:

    data SomeData a = SomeValue
                    | SomeConstructor a
    

    Instead, you should put the (Integral a) constraint on any functions that require it, which you’d have to do even if you added the constraint to the data definition too. Putting the constraint on the data definition buys you nothing, but forces you to carry around the constraint on all uses of SomeData, even those that don’t care what a is at all. See Chapter 10 of Real World Haskell for more.

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

Sidebar

Related Questions

It seems to be possible in Java to write something like this: private enum
I'm using propel master-dev with symfony 2.1. Is possible to write something like that
Is it possible to write template definition for this data type? myclass<int, myclass<int> >
I would like to write something to a file (a result obtained from GNUPG)
Is it possible to write something similar to mem_fun and bind1st etc. so that
Is it possible to write generic class with one constructor which explicitly defines type
Is it possible to write this query in codeigniter active records? $Main_Nav_Query = mysql_query(SELECT
I would like to use CouchDB to store some data for me and then
I have an Oracle table with data that looks like this: ID BATCH STATUS
I have to get some data that if possible should be done in one

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.