Defining types

Nick Kallen phantom@earthlink.net
Fri, 28 Nov 1997 13:02:33 -0800


>>:: Env a b :== [(a, b)]
>>:: Member (Env a b) :== (a, b)
>
>I am not sure what you want and why you want it?
>I suppose you are not happy with
>
>:: Env    a b :== [Member a b]
>:: Member a b :== (a, b)


Unfortunately, I am not happy with that. Suppose for example, that we have
some type:

:: Form :== Env [Char] [Char]

Lets assume for the context of this discussion that Form is imported
somehow, so the programmer has no way of knowing exactly how Form is
defined.
    Now, (to use the way Tiny is describd in "Parser Combinators")
statements would be of type (statements :: Parser Char Form)
    But what would stmt's type be? (stmt :: Parser Char ([Char], [Char]))
would be correct, but the problem is, how is the programmer to know that? If
they don't know the definition of Form--or even if they know the defintion
of Form but not of (Env a b)--then the programmer has no way of knowing.
    Now, we could use your definition of Member (:: Member a b :== (a, b)),
making (stmt :: Parser Char (Member [Char] [Char]). But the problem here is
that necesitates knowing the definition of Form (Env [Char] [Char])! What I
want to do is allow the programmer not to know the definition of Form so I
could (stmt :: Parser Char (Member Form)).

The whole motivation of this is to try to use abstract datatypes. The
"Parser Combinators" library is almost totally abstract, with the only
exception I can think of being <@. The convenience of using an ADT in this
context would be very useful--with environments, with parsers, etc.


>I have the feeling that what you want is functions on types (is that the
case?).
>This would indeed be a significant extension...

If what I'm describing is a function on Types, then I suppose that is what I
want. The thing is, when I see the code (:: Env a b :== [(a, b)]) I look at
it as a function on types.  Env being the function, a and b being two
parameters. It seems to me that the conceptual difference between the above
definition of Env and (:: Member (Env a b) :== (a, b)) is nonexistent.