mirror of
https://github.com/carp-lang/Carp.git
synced 2024-10-05 17:47:30 +03:00
Update Opaque docs; fix typos
This commit is contained in:
parent
5c170239c8
commit
b63f981575
@ -1,8 +1,8 @@
|
||||
(doc Opaque "The opaque type is an uninhabited type with no constructors.
|
||||
Opaque can be used to force some abstract type to range over a type constructor
|
||||
without concerning oneself with the inhabitant of the constructor--in other
|
||||
words, it may be used to enable a type to work for all inhabitants and can
|
||||
express relationships between types. It can facillitate generic programming.
|
||||
without concerning oneself with the inhabitant of the constructor. It may be
|
||||
used to enable a type to work for all inhabitants and can facillitate generic
|
||||
programming.
|
||||
|
||||
Consider an example:
|
||||
|
||||
@ -26,16 +26,20 @@ Consider an example:
|
||||
```
|
||||
|
||||
In the above example, the Opaque type allows us to define tabulate generically
|
||||
defined over Tuples without having to ensure their inhabitants match, allowing
|
||||
us to fully determine the resulting values type via tabulate's function
|
||||
argument. Without Opaque, Index would contain a generic type which would be
|
||||
unreseolved upon the call to `tabulate`. It allows us to ensure the `positions`
|
||||
we call are the positions of the correct constructor type `f` wihtout worrying
|
||||
having to restrict ourselves to only calling `Indexes` over an `f` of a
|
||||
specific type (e.g. `(f a)`)--in other words, it allows us to constrain
|
||||
functions by constructor types only.
|
||||
over Tuples without having to ensure their inhabitants match. The result of
|
||||
tabulate is fully determined by the Index passed to it, which determines the
|
||||
constructor that will be used, and the return type of its function argument.
|
||||
Without Opaque, Index would contain a generic type which would be unreseolved
|
||||
upon the call to `tabulate` and Carp would have no means of determining which
|
||||
implementation of `positions` to use (unless we used a `the` declaration or a
|
||||
similar mechanism). Opaque allows us to ensure the `positions` we call are the
|
||||
positions of the correct constructor type `f` wihtout having to restrict
|
||||
ourselves to only calling `Indexes` over an `f` with a specific inhabitant
|
||||
type (e.g. `(f a)`)--in other words, it allows us to constrain functions by
|
||||
constructor types only.
|
||||
|
||||
Thanks to Opaque, tabulate can generate an `(Array Int)`, `(Array Bool)`,
|
||||
`(Array String)` all solely dependent on the return type of `h`.
|
||||
`(Array String)`, `(Maybe Bool)`, etc. all solely dependent on the return type
|
||||
of `h` and the `f` in the given `Index`.
|
||||
")
|
||||
(deftype Opaque)
|
||||
|
Loading…
Reference in New Issue
Block a user