What is the difference at different stages of the pipeline with compilation readiness between the type declaration and the newtype declaration?
My assumption was that they were compiled with the same machine instructions and that the only difference was that the program was checked type, where, for example,
type Name = String newtype Name_ = N String
You can use Name anywhere a String , but typechecker will call you if you use Name_ , where String is expected, even if they encode the same information.
I ask a question because, if so, I see no reason why the following declarations should not be valid:
type List a = Either () (a, List a) newtype List_ a = L (Either () (a, List_ a))
However, the type of check accepts the second, but rejects the first. Why is this?
source share