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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:08:32+00:00 2026-05-24T14:08:32+00:00

This code will compile correctly: import Text.Printf import Test.HUnit doubleMe x = x +

  • 0

This code will compile correctly:

import Text.Printf
import Test.HUnit
doubleMe x = x + x
doubleUs x y = doubleMe x + doubleMe y
doubleSmallNumber x = if x > 100 then x else x*2
doubleSmallNumber' x = if x > 100 then x else x*2 + 1
conanO'Brien = "It's a-me, Conan O'Brien!"
main = do
  runTestTT $ TestList [TestCase $ ae 4 $ doubleMe 2,
                        TestCase $ ae 10 $ doubleUs 2 3,
                        TestCase $ ae 4 $ doubleSmallNumber 2,
                        TestCase $ ae 1000 $ doubleSmallNumber' 1000,
                        TestCase $ assertEqual "" "It's a-me, Conan O'Brien!" conanO'Brien]
  where ae = assertEqual "" 

The output is:

$ clear && ghc baby.hs && ./baby     
[1 of 1] Compiling Main             ( baby.hs, baby.o )
Linking baby ...
ld: warning: could not create compact unwind for .LFB3: non-standard register 5 being saved in prolog
Cases: 5  Tried: 5  Errors: 0  Failures: 0

When I change the code to:

import Text.Printf
import Test.HUnit
doubleMe x = x + x
doubleUs x y = doubleMe x + doubleMe y
doubleSmallNumber x = if x > 100 then x else x*2
doubleSmallNumber' x = if x > 100 then x else x*2 + 1
conanO'Brien = "It's a-me, Conan O'Brien!"
main = do
  runTestTT $ TestList [TestCase $ ae 4 $ doubleMe 2,
                        TestCase $ ae 10 $ doubleUs 2 3,
                        TestCase $ ae 4 $ doubleSmallNumber 2,
                        TestCase $ ae 1000 $ doubleSmallNumber' 1000,
                        TestCase $ ae "It's a-me, Conan O'Brien!" conanO'Brien]
  where ae = assertEqual "" 

I get:

[1 of 1] Compiling Main             ( baby.hs, baby.o )

baby.hs:12:65:
    No instance for (Num [Char])
      arising from the literal `1000'
    Possible fix: add an instance declaration for (Num [Char])
    In the first argument of `doubleSmallNumber'', namely `1000'
    In the second argument of `($)', namely `doubleSmallNumber' 1000'
    In the second argument of `($)', namely
      `ae 1000 $ doubleSmallNumber' 1000'

I don’t understand why.

Also does anybody have any ideas for fixing the ld warning:

ld: warning: could not create compact unwind for .LFB3: non-standard register 5 being saved in prolog
  • 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-24T14:08:33+00:00Added an answer on May 24, 2026 at 2:08 pm

    This is an example of the monomorphism restriction. ae “looks like a value” (doesn’t have arguments) and doesn’t have an explicit type, so compiler won’t infer a polymorphic type for it.

    In first example, it gets type Int -> Int -> Assertion (I think).

    In the second, from ae "It's a-me, Conan O'Brien!" conanO'Brien it gets the type String -> String -> Assertion. Remember that the type of integer literals is actually Num a => a, and 1000 gets type String from ae, so the compiler needs an instance Num String.

    EDITED: This can be fixed by giving an explicit type annotation: where ae :: (Show a, Eq a) => a -> a -> Assertion = assertEqual "". Or by adding arguments to definition (eta-expanding it): where ae x y = assertEqual "" x y.

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

Sidebar

Related Questions

Typically you will find STL code like this: for (SomeClass::SomeContainer::iterator Iter = m_SomeMemberContainerVar.begin(); Iter
Consider the following code: $(a).attr(disabled, disabled); In IE and FF, this will make anchors
I found the following code to create a tinyurl.com url: http://tinyurl.com/api-create.php?url=http://myurl.com This will automatically
This code does not seem to compile, I just need to write something to
This code in JS gives me a popup saying i think null is a
This code is from Prototype.js . I've looked at probably 20 different tutorials, and
this code always returns 0 in PHP 5.2.5 for microseconds: <?php $dt = new
This code works (C# 3) double d; if(d == (double)(int)d) ...; Is there a
This code always works, even in different browsers: function fooCheck() { alert(internalFoo()); // We
This code produces a FileNotFoundException, but ultimately runs without issue: void ReadXml() { XmlSerializer

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.