Singular Type Constructor

Ashley Yakeley
Thu, 9 Aug 2001 00:08:16 -0700

At 2001-08-08 23:00, Hal Daume III wrote:

>however, if you try something like:
>instance TypeName a where
>    typeName T = "??"
>it will complain because there must be one non-type variable in the
>instance head.

Try using "-fglasgow-exts -fallow-undecidable-instances".

>moreover, even if this restriction is removed (anyone know what it's
>there for?), there will be the problem of overlapping instances with,
>say TypeName Char and TypeName a.

Correct. And the instances really would overlap, it wouldn't just be GHC 
complaining that they _might_ overlap but not being able to figure out 
that they don't.

>so i'm wondering if there is a way to specify something like:
>instance Not (TypeName a) => TypeName a where ...


>that is, this type variable a matches with all a such that a is not an
>instance of TypeName...

If there were such a thing, it would be incoherent to say: "if a is not 
TypeName, then a is TypeName with this typeName".

>there are other places where i would find such a thing
>useful/interesting beyond this TypeName foo, but this seemed like a
>good, simple way to explain it...

Can you think of a use for it that isn't semantically incoherent?

Ashley Yakeley, Seattle WA