git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Update README.md
commit63c158af079eb2b1b87bb7f3ecf01f6c7df8e6a6 authorPhil Freeman <paf31@cantab.net> dateThu 28 Nov 2013, 14:19 (13 years ago) parenta21661d
1 file changed+28
README.md+28
README.md+28
@@ -15,6 +15,11 @@ A small strongly, statically typed compile-to-JS language with basic extensible
1515- Functions with multiple arguments
1616- Pattern matching
1717- Simple FFI
18+
19+## Experimental Features
20+
21+- Modules
22+- Rank N Types
1823
1924## Try It!
2025
@@ -318,6 +323,29 @@ since the `bar` property is missing.
318323
319324Again, a type annotation can be provided if necessary.
320325
326+## Rank N Types (Experimental Feature)
327+
328+It is also possible for the `forall` quantifier to appear on the left of a function arrow, inside types record fields and data constructors, and in type synonyms.
329+
330+In most cases, a type annotation is necessary when using this feature.
331+
332+As an example, we can pass a polymorphic function as an argument to another function:
333+
334+```haskell
335+poly :: (forall a. a -> a) -> Boolean
336+poly = \f -> (f 0 < 1) == f true
337+```
338+
339+Notice that the polymorphic function's type argument is instantiated to both `Number` and `Boolean`.
340+
341+An argument to `poly` must indeed be polymorphic. For example, the following fails:
342+
343+```haskell
344+test = poly (\n -> n + 1)
345+```
346+
347+since the skolemized type variable `a` does not unify with `Number`.
348+
321349## Type Inference
322350
323351All types can be inferred, but annotations can optionally be provided.