Quantcast
Channel: giving types for expressions - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by assembly.jc for giving types for expressions

$
0
0

To understand why the expression: [ [], [[]], [[[]]], [[[[]]]], [[[[[ ]]]]] ] has type [[[[[[a]]]]]], you need to understand what is the type of [] first.

Actually, [] is equivalent to [a'], where a' is type variable without any constraint. That means a' can be any type. So, when a list is constructed, say, [ [], [[]] ], it is legal to replace a' with [a] as:

[ [], [[]] ] ~ [ [a'] [[a]] ] ~ [ [[a]], [[a]] ] ~ [ [[a]] ]

The same reason why

[ [], [[]], [[[]]], [[[[]]]], [[[[[ ]]]]] ] ~  [ [[[[[a]]]]] ]

But when you constructs a list as [ [True], [[]] ], there is no way to convert True to a list, even though [a] can be any type of list. The same reason why [ [True], [[]], [[[]]], [[[[]]]], [[[[[]]]]] ] is illegal.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>