What does the `forall` keyword in Haskell/GHC do?

前端 未结 8 1724
[愿得一人]
[愿得一人] 2020-11-28 17:01

I\'m beginning to understand how the forall keyword is used in so-called \"existential types\" like this:

data ShowBox = forall s. Show s =>          


        
8条回答
  •  情话喂你
    2020-11-28 17:51

    The reason why there are different uses of this keyword is that it's actually used in at least two different type system extensions: higher-rank types, and existentials.

    It's probably best just to read about and understand those two things separately, rather than trying to get an explanation of why 'forall' is an appropriate bit of syntax in both at the same time.

提交回复
热议问题