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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:24:15+00:00 2026-06-02T20:24:15+00:00

I ran across something I find curious while playing around with the Haskell interactive

  • 0

I ran across something I find curious while playing around with the Haskell interactive prompt (ghci). The following code run under ghci 7.0.4

[minBound..1]

throws the following exception:

<interactive>:1:12:
    Ambiguous type variable `t0' in the constraints:
      (Num t0) arising from the literal `1' at <interactive>:1:12
      (Enum t0) arising from the arithmetic sequence `minBound .. 1'
                at <interactive>:1:1-13
      (Bounded t0) arising from a use of `minBound'
                   at <interactive>:1:2-9
    Probable fix: add a type signature that fixes these type variable(s)
    In the expression: 1
    In the expression: [minBound .. 1]
    In an equation for `it': it = [minBound .. 1]

I know that writing the above as [minBound..1 :: Int] would make it clear that ‘1’ here is meant to be an Int, but my question is, where does the ambiguity lie? ‘1’ could be interpreted as Int, Integer, Float or Double, but none of these except Int belong to the Bounded class. So is there another class that literal 1 could masquerade as? If not, then what?

  • 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-02T20:24:17+00:00Added an answer on June 2, 2026 at 8:24 pm

    Per the defaulting rules, a constrained type variable is tried to be resolved by defaulting, if

    • all constraints have the form C a; a doesn’t appear as an argument to a type constructor in the constraint, and
    • at least one of the classes involved is a numeric class,and
    • all of the classes are defined in the Prelude or the standard libraries.

    The inferred type of the expression [minBound .. 1] is

    [minBound .. 1] :: (Num a, Enum a, Bounded a) => [a]
    

    so the defaulting rules apply. But for defaulting, only types listed in the default declaration of the module are considered – in the absence of a default declaration, the default default of (Integer, Double) is assumed, i.e. to resolve a constrained ambiguous type variable, first Integer is tried, and if that doesn’t satisfy all constraints, Double is tried. If that doesn’t satisfy all constraints either, defaulting fails and the compilation fails with an ambiguous type variable error¹.

    In the case at hand, neither Integer nor Double satisfy the Bounded constraint, so defaulting fails.

    ¹ In ghci, or with the ExtendedDefaultRules extension enabled, defaulting is also attempted if no numeric class is among the constraints but Show is, and the default default is extended by ().

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

Sidebar

Related Questions

I'm playing around with using Simple.Data for my next project, and ran across something
I ran across the following code in Ely Greenfield's SuperImage from his Book component
Poking around in the rails code, I ran across with_scope . From what I
While trying to do something a bit more complicated, I ran across a behavior
i ran across something similar to the below code snippet, which throws a compiler
I'm doing some maintenance work and ran across something like the following: std::string s;
While revising some old c++ code, I ran across several bitflags defined as enums.
I recently ran across a set of code which instantiated local maps as following:
I ran across some code recently at work (recreated to be similar to what
I ran across a very strange line of code in a legacy Perl application.

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.