Primitive types and Prelude shenanigans

Ketil Malde
16 Feb 2001 07:21:46 +0100

William Lee Irwin III <> writes:

> Some analysis of the value of the literal would need to be
> incorporated so that something like the following happens:

> 	literal "0" gets mapped to zero :: AdditiveMonoid t => t
> 	literal "1" gets mapped to one :: MultiplicativeMonoid t => t

Indeed.  Is it a reasonable assumption that all values of literal "0"
are intended to be the additive identity element?  How about "1",
might we not have it as a successor element in a group, where
multiplication isn't defined?

I guess other behaviour (e.g. using implicit fromInteger) assumes even
more about the classes that can be represented by literal numbers, so
it appears this would be an improvement, if it is at all workable.

> 	literal "5" gets mapped to (fromPositiveInteger 5)

Is something like
        (fromInteger 5) *> one 
(where *> is Module scalar multiplication  from the left?  Could we
avoid having lots and lots of from* functions?

I guess having to declare any datatype as Module is as bad as the
explicit conversion functions...

Anyway, I like it, especially the zero and one case.

> I think Dylan Thurston's proposal is probably the best starting point
> for something that should really get support.

Indeed.  How far are we from being able to import it, e.g. with
"import DTlude as Prelude" or whatever mechanism, so that we can
start to play with it, and see how it works out in practice?

If I haven't seen further, it is by standing in the footprints of giants