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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:33:38+00:00 2026-05-26T23:33:38+00:00

would like to print a random number between 0 and 10, but generate seems

  • 0

would like to print a random number between 0 and 10, but generate seems undefined
can not be compiled, the following code edited from example
i am using Haskell Platform 2011.2.0.1

Updated:

import System.IO
import System.Random
import Test.QuickCheck.Function
import Test.QuickCheck.Gen
import Test.QuickCheck

main :: IO() 
main = putStrLn (show result)
  where result = unGen (choose (0, 10)) (mkStdGen 1) 1

The resulting error:

test6.hs:13:25:
    Ambiguous type variable `a0' in the constraints:
      (Random a0) arising from a use of `choose' at test6.hs:13:25-30
      (Show a0) arising from a use of `show' at test6.hs:12:18-21
      (Num a0) arising from the literal `10' at test6.hs:13:36-37
    Probable fix: add a type signature that fixes these type variable(s)
    In the first argument of `unGen', namely `(choose (0, 10))'
    In the expression: unGen (choose (0, 10)) (mkStdGen 1) 1
    In an equation for `result':
        result = unGen (choose (0, 10)) (mkStdGen 1) 1
  • 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-26T23:33:38+00:00Added an answer on May 26, 2026 at 11:33 pm

    Ok, first problem is that let makes a local binding, and you are using it in global scope, if you want the binding to be local to the main action, I would use where to do the binding. Looking at the QuickCheck docs it appears that the generate function no longer exists. unGen has the same type signature so I believe that has replaced it.

    import System.Random
    import Test.QuickCheck
    import Test.QuickCheck.Gen
    
    main :: IO ()
    main = putStrLn (show result)
      where result = unGen (choose (0::Int, 10::Int)) (mkStdGen 1) 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to generate a random floating point number between 2 values. What
So, I've got my code ready to generate and print a random number between
Given a regexp, I would like to generate random data x number of time
I would like to generate a random number string of N length with this
I would like to write a code to generate a dataset censored with 1
I would like to print only the contents of a textarea element from a
I would like to print scrollable div as WYSWYG. Is there a way?
I would like to print an array to a file. I would like the
I would like to print the selected values of all selects using jQuery. I
I have a string that I would like to print . Is it possible

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.