git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Update README.md
63c158aPhil Freeman
README.md+28
@@ -15,6 +15,11 @@ A small strongly, statically typed compile-to-JS language with basic extensible
15- Functions with multiple arguments
15- Functions with multiple arguments
16- Pattern matching
16- Pattern matching
17- Simple FFI
17- Simple FFI
18+
19+## Experimental Features
20+
21+- Modules
22+- Rank N Types
18
23
19## Try It!
24## Try It!
20
25
@@ -318,6 +323,29 @@ since the `bar` property is missing.
318
323
319Again, a type annotation can be provided if necessary.
324Again, a type annotation can be provided if necessary.
320
325
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+
321## Type Inference
349## Type Inference
322
350
323All types can be inferred, but annotations can optionally be provided.
351All types can be inferred, but annotations can optionally be provided.