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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:42:11+00:00 2026-06-12T16:42:11+00:00

This function: hola :: (Integral a) => a -> String hola 1 = OK

  • 0

This function:

hola :: (Integral a) => a -> String
hola 1 = "OK"
hola _ = "asdf"

works fine. But this one:

hola :: (Num a) => a -> String
hola 1 = "OK"
hola _ = "asdf"

can’t be compiled: “Could not deduce (Eq a) arising from the literal `1′”

I really don’t get it. I am reading a tutorial where it is said

“Integral is also a numeric typeclass. Num includes all numbers, including real numbers and integral numbers, Integral includes only integral (whole) numbers. In this typeclass are Int and Integer.” http://learnyouahaskell.com/types-and-typeclasses

Why can’t I use Num?

  • 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-12T16:42:12+00:00Added an answer on June 12, 2026 at 4:42 pm

    It’s a recent change proposed and accepted in September/October last year, in the latest version of the base package, Eq and Show are no longer superclasses of Num. Since that change, no new version of the language report has been published, so it’s not yet in the report. And since it’s recent, it has also not made it yet into many tutorials or books.

    “Pattern matching” against a numeric literal is an implicit application of (==), so an Eq instance is required for it to work. That instance can now no longer be inferred from the Num constraint, so the (quite new :D) compiler rejects the code with only a Num constraint.

    But Integral is a subclass of Real, which has Ord (and hence Eq) as a superclass, hence that works.

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

Sidebar

Related Questions

This function works fine: std::string get_str() { return std::get<0>( make_tuple(std::string(hi)) ); } But if
This function works fine if I disable errors. But I have to solve them.
This function alerts right totalqt only when I check checkboxes one by one. But
This function works perfectly fine, or so the compiler/debugger tells me void GUIManager::init(ToScreen* tS)
This function works well, but it always returns the same value because I don't
This function works perfectly on IE, Firefox and Chrome but when on the iPhone,
This function works as it should, window.setInterval(function(){ var active = $('#frontpageControls a.active'); var next
This function only works once, when I click an anchor element again, nothign happens.
I have this code: (function ($) { $(document).ready(function() { test(hola,caracola); }); function test(somevar1, somevar2)
this function is called automatically when quit application..but in my application this function cannot

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.