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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:08:03+00:00 2026-06-03T01:08:03+00:00

How do I generate a random GLfloat value in Haskell? There is no instance

  • 0

How do I generate a random GLfloat value in Haskell?

There is no instance declaration for Random GLfloat.

  • 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-03T01:08:04+00:00Added an answer on June 3, 2026 at 1:08 am

    When there is no instance, make an instance. That’s the first thing they teach you.

    There are many ways, but the easiest is probably to generate a type of sufficient resolution then cast that to a GLfloat:

    instance Random GLfloat where
        random g = 
            let f :: Double
                (f,g2) = random g
            in (fromRational (toRational f), g2)
    

    Double should suffice seeing as that’s a 64 bit floating value while GLFloat (which wraps CFloat) is a 32 bit float. Float should be sufficient, but I’m not well-versed enough in the specifics of Floating point to know for sure that this is true for all platforms.

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

Sidebar

Related Questions

How do I generate random numbers in a microcontroller efficiently? Are there any general
I need to generate random BigDecimal value from given range. How to do it
I want to generate random colours which can be attractive in pie charts.I have
I used to generate random string in the following way (now I've switched to
I want to generate random numbers from -n to n excluding 0. Can someone
How to generate random number from an array? and not from a range. int
How to generate random numbers using assembly code in the range 1--4 ?
I actually want to generate random password using PHP uniqid() function $randomPassword = uniqid();
I'm using srandom() and random() to generate random numbers in c on a Unix
Simple enough question: I'm using python random module to generate random integers. I want

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.