Hacker News new | ask | show | jobs
by consilient 1250 days ago
> The Computer has N bytes of memory. You want to declare a Boolean type variable. You tell your compiler this by coding it in the language of your choice. The compiler will typically allocate 1 to 8 bytes of memory to store that Boolean value -- depending on such things as how many bits your CPU is, what compiler options are, if variables should be byte or dword or qword aligned in memory, etc.

You're confusing several things here.

- a term is not its runtime representation

- a type is not the set of all terms that inhabit it (though you can get away with pretending it is in simple cases)

- and more generally, operational semantics are not denotational semantics

> So they are all-inclusive sets of some larger universe of values?

No, they're simply not sets. Types are primitive notions in type theories, the same way that sets are the primitive notions of set theory. No reduction of one to the other is necessary or, typically, desirable.

And even if you try to build type theory on set-theoretic foundations - which is 100% the wrong choice if you want to apply it to computational problems down the line - you're still going to run into problems once things start getting recursive. Consider, for example, the type of "hyperfunctions" given by

`type Hyper a b = Hyper b a -> b`

This is too big to be a set, for the usual self-containment reasons. But it's a perfectly legitimate Haskell type, modulo syntax. I've used it in real code.

> use a single solitary type that represents the larger universe of all possible values everywhere that a type is used?

That's what a dynamically typed programming language is.

1 comments

> You're confusing several things here.

I think the problem is that the parent tries to look at quite advanced topics without understanding anything about the foundations.

I'm not sure repeating already stated facts will change much therefore.

He was given already quite good sources to learn more. Now it's on him to understand those things.

(Of course things would be simpler if he would asks questions instead of insisting on his misunderstandings.)

> > use a single solitary type that represents the larger universe of all possible values everywhere that a type is used?

LOL, the all mighty uni-type! :-D

But I see here more people that confuse mere runtime values with types…

I fear too much exposition to "dynamic" languages (or maybe also static languages with "type values") causes some severe damage to future understanding of PLT concepts and confuses people.

I think some PLT / functional programming needs to be thought early in school as part of the math education. This would likely prevent some of damage form being exposed to imperative programming and/or dynamic languages later on.

Just my 2ct.

consilient/still_grokking -- this is my response to both of you:

You have the Natural Numbers, N.

You have the Integers, Z.

You have the Rational Numbers, Q.

You have the Real Numbers, R.

You have the Complex Numbers, C.

(https://en.wikipedia.org/wiki/Number#Classification)

My question to (both of) you -- is simply this:

Are those designations, N,Z,Q,R,C -- TYPES?

Or are they not TYPES?

Answer me that with a yes/no answer -- before we proceed.

Are the domains for numbers in Mathematics TYPES?

Or are they not TYPES?

?

The answer(s) to this question depend(s) on which foundation of number theory you like to use.

The classical foundation of number theory is set theory. (No types there!)

But you could actually base number theory also on type theory… (No clue whether someone did this actually).

The result may differ than, I think.

Is a subset of a set -- a TYPE?

?

Dude…

No.

Have you tried google?

Maybe even ChatGPT "knows" enough to help you.

Question:

Why are types -- used at all?

In Computer Programming or in Mathematics?

Surely types -- must have some purpose -- otherwise, WHY are they used at all?

?

So N,Z,Q,R,C -- are not subsets of the set of all possible numbers?

?

Also...

Does there exist at least one subset of all of the sets in existence -- which is a type?

?