[Haskell-cafe] Generating random enums

michael rice nowgate at yahoo.com
Sat May 2 14:54:21 EDT 2009

I intuited that that's what the problem was.



--- On Sat, 5/2/09, Rahul Kapoor <rk at trie.org> wrote:

From: Rahul Kapoor <rk at trie.org>
Subject: Re: [Haskell-cafe] Generating random enums
To: "michael rice" <nowgate at yahoo.com>
Cc: "John Van Enk" <vanenkj at gmail.com>, haskell-cafe at haskell.org
Date: Saturday, May 2, 2009, 2:00 PM

> OK, I think what you're saying is to work with (random) integers and use
> fromEnum and toEnum to get corresponding DayOfWeek. But I get this when I
> try to use toEnum:
> *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'

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090502/29b0c9ea/attachment.htm

More information about the Haskell-Cafe mailing list