[Haskell-cafe] Generating random enums
ketil at malde.org
Sat May 2 15:22:26 EDT 2009
Rahul Kapoor <rk at trie.org> writes:
>> *Main> toEnum 2
> ghci does not know what type of enum you want to create from the number 2.
> Try: toEnum 2 :: DayOfWeek
> That said, I would expect "toEnum 2" to give an error like: 'Ambiguous
> type variable `a'....'. So I am not sure why your error message says:
> '** Exception: Prelude.Enum.().toEnum: bad argument'
Wild guess: The dread monomorphism restriction uses () as a reasonable
type, and it only has one element. Does 'toEnum 0' give '()' as the
(I couldn't reproduce it with my version of GHCi - I get the ambigous
type error message)
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe