Hi Scott,

|     -- a synonym for [(i,e)]
|     type X i e = [(i,e)]
|     -- The synonym X is meaningful, and can be used to define a function.
|     foo :: Ix i => i -> X i e -> Maybe e
|     foo i ls = lookup i ls
| 
|     -- This is what we _really_ want X for:
|     instance Ix i => Find X i e where
|       find = foo
| 
| The last instance declaration has the same explicit structure as the
| instance declaration for Y, but it is rejected by Hugs with the 
| error message:
|   Not enough arguments for type synonym "X"
| 
| I believe that if nothing else, the error message is wrong.

No, the error message is correct.  It is not legal for a type synonym
to be partially applied, and this is the same for Haskell and for Hugs.
If X has two parameters in its definition, then it must also have two
parameters at each call.  Your `analogous' definition type Y = Array is
not as good an analogy as you had hoped because it doesn't give Y any
parameters, and hence doesn't need any either when it is called.

The reason that we don't allow partially applied type synonyms is the
same reason that we don't allow lambdas in type expressions (what you
really wanted here, I think, was \i e -> [(i,e)]): we don't know how
to deal with these in a satisfactory manner, particularly during type
inference.  In general, this requires higher-order unification, which
is not unitary (no most general unifiers), and not decidable (may not
terminate).  There are some interesting possibilities that might help
to address these problems.  However, for the time being, it still
looks like a hard problem.

All the best,
Mark

Reply via email to