On Thu, Jan 17, 2013 at 8:40 PM, Rustom Mody <rustompmody@gmail.com> wrote:
And I need to do things like
type Vertex = Ix a => a
(so that a vertex can be used to index an adjacency-list-array)Two things seem to be going on:(1) you're trying to define a data type using "type" and not "data"+class instances. Recall that the "type" declares a type /synonym/, and while type synonyms seem to behave like CPP-style macros, they aren't.That is to say that whenever 'Vertex' appears in a type signature, the Ix should 'float' out to the qualifier list
(2) you're trying to save on keyboarding by using Vertex as a CPP-style macro that expands in the "smart" way you just described. Something that has been requested before is collapsing a list of constraints into just one (search haskell-cafe archives and also see "No Module Abstraction" of [1]). The larger the number of constraints, i.e. (A x) expands out to (B x, C x, D x, ...) the greater the need for such a feature. But there's no benefit to be gained here.(3) you're trying to improve readability of code because "Ix a => a" isn't explicit that type variable "a" is a vertex. Nothing stops you from writing "Ix vertex => vertex" however. See [2].
my aesthetic choice: I don’t obscure my code’s inner beauty behind repulsive indecipherable type signatures…