... | ... | @@ -141,68 +141,82 @@ These functions are defined in module `Type`. |
|
|
## Classifying types
|
|
|
|
|
|
|
|
|
|
|
|
GHC uses the following nomenclature for types:
|
|
|
|
|
|
<table><tr><th>**Unboxed**</th>
|
|
|
|
|
|
<table><tr><th><b>Unboxed</b></th>
|
|
|
<td>A type is unboxed iff its representation is other than a pointer. Unboxed types are also unlifted.
|
|
|
</td></tr></table>
|
|
|
|
|
|
<table><tr><th>**Lifted**</th>
|
|
|
|
|
|
<table><tr><th><b>Lifted</b></th>
|
|
|
<td>A type is lifted iff it has bottom as an element. Closures always have lifted types: i.e. any let-bound identifier in Core must have a lifted type. Operationally, a lifted object is one that can be entered. Only lifted types may be unified with a type variable.
|
|
|
</td></tr></table>
|
|
|
|
|
|
<table><tr><th>**Data**</th>
|
|
|
<td>A type declared with **`data`**. Also boxed tuples.
|
|
|
|
|
|
<table><tr><th><b>Data</b></th>
|
|
|
<td>A type declared with <b><tt>data</tt></b>. Also boxed tuples.
|
|
|
</td></tr></table>
|
|
|
|
|
|
<table><tr><th>**Algebraic**</th>
|
|
|
<td>An algebraic data type is a data type with one or more constructors, whether declared with `data` or `newtype`. An algebraic type is one that can be deconstructed with a case expression. "Algebraic" is **NOT** the same as "lifted", because unboxed (and thus unlifted) tuples count as "algebraic".
|
|
|
|
|
|
<table><tr><th><b>Algebraic</b></th>
|
|
|
<td>An algebraic data type is a data type with one or more constructors, whether declared with <tt>data</tt> or <tt>newtype</tt>. An algebraic type is one that can be deconstructed with a case expression. "Algebraic" is <b>NOT</b> the same as "lifted", because unboxed (and thus unlifted) tuples count as "algebraic".
|
|
|
</td></tr></table>
|
|
|
|
|
|
<table><tr><th>**Primitive**</th>
|
|
|
<td>a type is primitive iff it is a built-in type that can't be expressed in Haskell.
|
|
|
|
|
|
<table><tr><th><b>Primitive</b></th>
|
|
|
<td>a type is primitive iff it is a built-in type that can't be expressed in Haskell.
|
|
|
|
|
|
Currently, all primitive types are unlifted, but that's not necessarily the case. (E.g. Int could be primitive.)
|
|
|
Currently, all primitive types are unlifted, but that's not necessarily the case. (E.g. Int could be primitive.)
|
|
|
</td></tr></table>
|
|
|
|
|
|
|
|
|
>
|
|
|
>
|
|
|
> Some primitive types are unboxed, such as Int\#, whereas some are boxed but unlifted (such as `ByteArray#`). The only primitive types that we classify as algebraic are the unboxed tuples.
|
|
|
>
|
|
|
>
|
|
|
|
|
|
|
|
|
Examples of type classifications:
|
|
|
|
|
|
<table><tr><th></th>
|
|
|
<th>**Primitive**</th>
|
|
|
<th>**Boxed**</th>
|
|
|
<th>**Lifted**</th>
|
|
|
<th>**Algebraic**</th></tr>
|
|
|
<tr><th>`Int#`</th>
|
|
|
|
|
|
<table><tr><th> </th>
|
|
|
<th> <b>Primitive</b> </th>
|
|
|
<th> <b>Boxed</b> </th>
|
|
|
<th> <b>Lifted</b> </th>
|
|
|
<th> <b>Algebraic</b>
|
|
|
</th></tr>
|
|
|
<tr><th> <tt>Int#</tt> </th>
|
|
|
<th> Yes </th>
|
|
|
<th> No </th>
|
|
|
<th> No </th>
|
|
|
<th> No
|
|
|
</th></tr>
|
|
|
<tr><th>`ByteArray#`</th>
|
|
|
<tr><th> <tt>ByteArray#</tt> </th>
|
|
|
<th> Yes </th>
|
|
|
<th> Yes </th>
|
|
|
<th> No </th>
|
|
|
<th> No
|
|
|
</th></tr>
|
|
|
<tr><th>`(# a, b #)`</th>
|
|
|
<tr><th> <tt>(# a, b #)</tt> </th>
|
|
|
<th> Yes </th>
|
|
|
<th> No </th>
|
|
|
<th> No </th>
|
|
|
<th> Yes
|
|
|
</th></tr>
|
|
|
<tr><th>`( a, b )`</th>
|
|
|
<tr><th> <tt>( a, b )</tt> </th>
|
|
|
<th> No </th>
|
|
|
<th> Yes </th>
|
|
|
<th> Yes </th>
|
|
|
<th> Yes
|
|
|
</th></tr>
|
|
|
<tr><th>`[a]`</th>
|
|
|
<tr><th> <tt>[a]</tt> </th>
|
|
|
<th> No </th>
|
|
|
<th> Yes </th>
|
|
|
<th> Yes </th>
|
|
|
<th> Yes
|
|
|
</th></tr></table> |
|
|
\ No newline at end of file |
|
|
</th></tr></table>
|
|
|
|
|
|
|