[firstname.lastname@example.org: Re: Enum class]
Thu, 25 Oct 2001 18:16:09 +0900
Content-Type: text/plain; charset=us-ascii
(I want to trim the headers, but don't know the history of this
thread. Also cc:ed back to the Haskell list.)
On Thu, Oct 25, 2001 at 11:11:42AM +0200, Ketil Malde wrote:
> Dylan Thurston <email@example.com> writes:
> > I agree that Enum instances for Float/Double are not likely to be
> > useful.
> From a gut feeling, I could see a use for expressions like
> [1.5, 1.6..] and [1.5, 1.6..2.0]
> (i.e. enumFromThen and enumFromThenTo) but enumFrom and enumFromTo
> making list of rounded integers seems strange to me.
> It seems to me that enumFromThen and -To could be implemented
> something like:
> enumFromThen beg next =3D beg : enumFromThen next (next+delta)
> where delta =3D next-beg
> similarly for enumFromThenTo, of course.
> i.e. depending only on functionality found in Num. Why not put these
> functions there, and remove Float and Double as Enum instances?
> What am I missing?
Currently you can write
data Day =3D Sunday | Monday | Tuesday | Wednesday | Thursday | Friday |
weekdays =3D [Monday..Friday]
which has nothing to do with Num.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
-----END PGP SIGNATURE-----