Skip to content

Instantly share code, notes, and snippets.

@mklinik
Created February 11, 2012 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mklinik/1803869 to your computer and use it in GitHub Desktop.
Save mklinik/1803869 to your computer and use it in GitHub Desktop.
import qualified Random
-- randomEnum :: (Enum a, Bounded a) => IO a
randomEnum = do
let minBoundInt = fromEnum (minBound::a)
let maxBoundInt = fromEnum (maxBound::a)
randomInt <- Random.randomRIO (minBoundInt, maxBoundInt)
return $ toEnum randomInt
Util.hs:15:31:
No instance for (Bounded a)
arising from a use of `minBound'
In the first argument of `fromEnum', namely `(minBound :: a)'
In the expression: fromEnum (minBound :: a)
In an equation for `minBoundInt':
minBoundInt = fromEnum (minBound :: a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment