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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:57:22+00:00 2026-06-04T19:57:22+00:00

As a beginner, it’s not obvious to me why this is not allowed: data

  • 0

As a beginner, it’s not obvious to me why this is not allowed:

data Pair = Pair a b

That is, why do Pair 5 "foo" and Pair 'C' [] HAVE to produce different types? Why is it not allowed for them both to create values of type Pair?

I’m learning from “Learn you a”, RWH, and the Haskell WikiBook, but have not been able to find the kind of precise, wonky language describing parametrized types that I’m looking for.

  • 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-04T19:57:23+00:00Added an answer on June 4, 2026 at 7:57 pm

    Fundamentally, the issue is that you would have no information about the contents of Pair. If all you know is that it contains a value of any type, the only real function you could use on it would be id, which is pretty useless!

    The problem is that, since each value could be anything, you have no guarantees about them at all. So you couldn’t even use ==: what if the value was a function? You can’t compare functions for equality!

    Imagine writing a function acting on your hypothetical Pair type:

    fn (Pair a b) = ...
    

    What other functions could you use on a and b?

    Anything with any sort of concrete type (e.g. Int -> Int or something) wouldn’t work because you can’t tell if a is an Int. More complicated types like Num n => n -> n wouldn’t work because you don’t even know if a is a number. The only functions that would work are ones with types like t1 -> t1 or t1 -> t2. However, the only reasonable function of the first type is id and there is no reasonable function of the second type at all.

    Now, you could just say “I’m going to try this function, if the type doesn’t work, throw an error.” But this would then be dynamic typing and would basically be throwing away the type system entirely. This sounds horrible, but it might make sense sometimes, so you can use Data.Dynamic to accomplish something like that. However, you shouldn’t worry about it as a beginner and chance are you will never need to use it–I haven’t, so far. I’m just including it for the sake of completeness.

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

Sidebar

Related Questions

Total beginner with PHP: I have an form based on table data that the
Absolute beginner question: I have a template file index.html that looks like this: ...
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Rails beginner here.. I have a users resource where I implemented a callback that's
Beginner programmer here....hope it makes sense :) I have created a console app that
Beginner here: In this answer to my question of how to insert data into
Android beginner, Can anybody guide me on this ? I do have the distance,
A beginner question... I have a list like this: x <- c(aa=v12, bb=x21, cc=f35,
Beginner rails/javascript question: Let's say that I have a simple Circle model in a
beginner to python here. I have 2 nested lists that I want to merge:

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.