r/purescript • • Feb 12 '16

Why have explicit universal quantification?

It seems to me, coming from Haskell, that requiring every type signature to include the explicit universal quantification just leads to a lot of line noise. Particularly when there's also a typeclass constraint.

Are there plans to make a compiler option that would remove the need to explicitly give the universal qualification? Why was it even chosen in the first place?

5 Upvotes

5 comments sorted by

View all comments

Show parent comment

2

u/FranklinChen Feb 13 '16

Here's information about higher-rank types, which are an extension in Haskell but are a standard part of PureScript: https://wiki.haskell.org/Rank-N_types and a tutorial https://ocharles.org.uk/blog/guest-posts/2014-12-18-rank-n-types.html

You need an explicit forall in order to write functions that have types such as

testLength : (forall a . Array a -> Number) -> Boolean

Note that this is a very different type from

somethingElse : forall a . (Array a -> Number) -> Boolean

2

u/Lokathor Feb 13 '16

Hmm, this does seem pretty cool.

However, I still think that a compiler flag or pragma to allow automatic rank 1 quantification on all of the functions within a module would be a good thing, simply to cut down on line noise.