[TYPES] a naive question on datatype declarations

Jon Sterling jon at jonmsterling.com
Sat Jan 27 04:27:22 EST 2024


Hi Gershom,

This is a good question, and often overlooked. Bob Harper taught me to think of these things as abstract types, and I agree — so the thing that makes two different datatype declarations different is the existing abstraction mechanism of your language. When you think of it this way, you think of the pattern-matching forms as being elaborated to some kinds of destructors or combinators — which are themselves part of the abstract interface of the type.

I cannot confirm because I don't remember the code, but it may be that the TILT compiler actually worked this way. Probably Bob will have a fresher recollection of this.

Best,
Jon


On Fri, Jan 26, 2024, at 10:18 PM, Gershom B wrote:
> [ The Types Forum, http://lists.seas.upenn.edu/mailman/listinfo/types-list ]
>
> In typical treatments of languages with recursive types, we present a
> syntax with either isorecursive or equirecursive types. But we do not
> have a syntax for introduction of type declarations.
>
> This is to say that we assemble types out of constructors for e.g.,
> polymorphism, recursion, sum, product, unit, exponential (give or
> take).
>
> But we do not have the equivalent of a "data" declaration in Haskell
> that lets us explicitly say
>
> data Bool = True | False
>
> or
>
> data List a = Nil | Cons a
>
> It is, I suppose, expected that readers of these papers can think
> through how to translate any given data datatypes in languages with
> explicit declaration into the underlying fixed type calculus.
>
> However, I am curious if there is any reference for *explicit*
> treatment of the syntax for datatype declarations and semantic
> modeling of such?
>
> One reason for such would be that in the calculi I described above,
> there's of course no way to distinguish between the above `data Bool`
> and e.g. `1 + 1`, while it might be desirable to maintain that strict
> distinction between actual equality and merely observable isomorphism.
>
> Thanks,
> Gershom


More information about the Types-list mailing list