Why is forall required to have a polymorphic type in the data definition?

It seems I need to explicitly say forallin order to have a parametric type in the data definition. For example, this

data A = A (forall s. ST s (STUArray s Int Int))

will work while this one

data A = A (ST s (STUArray s Int Int))

will not.

Perhaps I am asking something too obvious, but the reason for this is not clear to me, because in most other cases you do not need an explicit forallparameter type; the compiler does this instead. What is the difference here?

+4
source share
1 answer

There are two different places where you can go forall, only one of which is what you intend. The other is

data A = forall s . A (ST s (STUArray s Int Int))

GADT

data A where
  A :: ST s (STUArray s Int Int) -> A

ST s , . ST, .

+7

Source: https://habr.com/ru/post/1607488/


All Articles