|
| 1 | +## Reference |
| 2 | + |
| 3 | +> Q. Where can we learn about the programming medium covered by this datasheet? |
| 4 | +> (Feel free to link to multiple kinds of artifacts: repositories, papers, videos, etc. |
| 5 | +> Please also include version information where applicable.) |
| 6 | +
|
| 7 | +- **Website**: http://hazel.org |
| 8 | +- **Source Code**: https://github.com/hazelgrove/hazel |
| 9 | +- **App**: https://hazel.org/build/dev/ |
| 10 | + |
| 11 | +> Q. What is the URL of the version of the benchmark being used? |
| 12 | +https://github.com/brownplt/B2T2/blob/fd227efadf532a20aefd25c7a8580978c2d684a2/Datasheet.md |
| 13 | + |
| 14 | + |
| 15 | +> Q. On what date was this version of the datasheet last updated? |
| 16 | +2025-11-05 |
| 17 | + |
| 18 | +> Q. If you are not using the latest benchmark available on that date, please explain why not. |
| 19 | +Yes |
| 20 | + |
| 21 | +## Example Tables |
| 22 | + |
| 23 | +> Q. Do tables express heterogeneous data, or must data be homogenized? |
| 24 | + Hazel tables are represented as *lists of labeled tuples*. |
| 25 | + - Columns may be heterogeneously typed. |
| 26 | + - Rows must be homogeneously typed. |
| 27 | + - The unknown type allows some degree of heterogenous rows. |
| 28 | + |
| 29 | +> Q. Do tables capture missing data and, if so, how? Do missing values affect the output constraints of any operations, |
| 30 | + for example `groupBy`? |
| 31 | + - Represented via `Option` types (`Some` / `None`) |
| 32 | + - Incomplete programs can use expression holes (holes are not programmatically discernible) |
| 33 | + - No special handling in operations — `Option` values are ordinary |
| 34 | + |
| 35 | +> Q. Are mutable tables supported? Are there any limitations? |
| 36 | +Mutable tables are not supported |
| 37 | + |
| 38 | +> You may reference, instead of duplicating, the responses to the above questions in answering those below: |
| 39 | +
|
| 40 | +> Q. Which tables are inexpressible? Why? |
| 41 | +
|
| 42 | +None — all tables can be expressed using `Option` types for missing data |
| 43 | + |
| 44 | +> Q. Which tables are only partially expressible? Why, and what’s missing? |
| 45 | +
|
| 46 | +N/A |
| 47 | + |
| 48 | +> Q. Which tables’ expressibility is unknown? Why? |
| 49 | +
|
| 50 | +N/A |
| 51 | + |
| 52 | +> Q. Which tables can be expressed more precisely than in the benchmark? How? |
| 53 | +
|
| 54 | +None - hazel represents the tables as precisely as the benchmark. Once again explicit option types make optional |
| 55 | +columns explicit. |
| 56 | + |
| 57 | +> Q. How direct is the mapping from the tables in the benchmark to representations in your system? How complex |
| 58 | +is the encoding? |
| 59 | + |
| 60 | + - Very direct |
| 61 | + - Benchmark tables map naturally to Hazel's `List of Labeled Tuples` |
| 62 | + - Missing values use `Option` |
| 63 | + - Nested tables use nested labeled tuples or lists |
| 64 | + |
| 65 | +## TableAPI |
| 66 | + |
| 67 | +> Q. Are there consistent changes made to the way the operations are represented? |
| 68 | +The operations are mostly presented as depicted, but here are a few variations: |
| 69 | +- Some operations utilize explicity polymorphism in Hazel using the `typfun` keyword to require explicit type |
| 70 | + application as implicit polymorphism has not been added to Hazel as of 2025-07-08 |
| 71 | +- Hazel tables are represented using lists of labeled tuples so there is no runtime schema available for operations. |
| 72 | + For certain operations, such as `leftJoin`, this requires looking at the head element to determine the schema and |
| 73 | + give some behavior in the event no such element exists. |
| 74 | +- Certain operations have been made to return an optional value rather than an error |
| 75 | +- Hazel does not have first-class labels, and therefore uses strings for columns for some of the operations. |
| 76 | + If the operation was done inline primitive operators could be used to recover typesafety. |
| 77 | + |
| 78 | +> Q. Which operations are entirely inexpressible? Why? |
| 79 | +All the operations are at least partially expressible. |
| 80 | + |
| 81 | +> Q. Which operations are only partially expressible? Why, and what’s missing? |
| 82 | +- `leftJoin` can only build the resulting columns if both tables have at least one row to determine the schema |
| 83 | +- Various operations only work if there's at least one row to determine the schema |
| 84 | + - ncols, header |
| 85 | +- `dropna` only works if every column in a table is optional since there's no way to dynamically dispatch based off of |
| 86 | + column sort. |
| 87 | + |
| 88 | +> Q. Which operations’ expressibility is unknown? Why? |
| 89 | +N/A |
| 90 | + |
| 91 | +> Q. Which operations can be expressed more precisely than in the benchmark? How? |
| 92 | +- Several operations could be expressed in a more typesafe manner if a projection function was passed instead of a |
| 93 | + column name. |
| 94 | + - e.g. `selectColumn(table, fun e -> e.name)` as opposed to `selectColumn(table, `name`)` |
| 95 | + |
| 96 | +## Example Programs |
| 97 | + |
| 98 | +> Q. Which examples are inexpressible? Why? |
| 99 | +- sampleRows is inexpressible as Hazel is pure |
| 100 | + |
| 101 | + |
| 102 | +> Q. Which examples’ expressibility is unknown? Why? |
| 103 | +N/A |
| 104 | + |
| 105 | +> Q. Which examples, or aspects thereof, can be expressed especially precisely? How? |
| 106 | +The examples are expressed as precisely as the benchmark |
| 107 | + |
| 108 | +> Q. How direct is the mapping from the pseudocode in the benchmark to representations in your system? How complex is |
| 109 | + the encoding? |
| 110 | +- The mapping is quite direct as implemented. A less direct mapping could accomplish a more type-safe translation of |
| 111 | + several of the programs. |
| 112 | + |
| 113 | +## Errors |
| 114 | + |
| 115 | +> There are (at least) two parts to errors: representing the source program that causes the error, and generating output |
| 116 | +> that explains it. The term “error situation” refers to a representation of the cause of the error in the program |
| 117 | +> source. |
| 118 | +> |
| 119 | +> For each error situation it may be that the language: |
| 120 | +> |
| 121 | +> - isn’t expressive enough to capture it |
| 122 | +> - can at least partially express the situation |
| 123 | +> - prevents the program from being constructed |
| 124 | +> |
| 125 | +> Expressiveness, in turn, can be for multiple artifacts: |
| 126 | +> |
| 127 | +> - the buggy versions of the programs |
| 128 | +> - the correct variants of the programs |
| 129 | +> - the type system’s representation of the constraints |
| 130 | +> - the type system’s reporting of the violation |
| 131 | +
|
| 132 | +> Q. Which error situations are known to be inexpressible? Why? |
| 133 | +Many of the programs require explicit parametric polymorphism and the higher-order function versions of the TableAPI |
| 134 | +operations to get the best feedback. |
| 135 | + |
| 136 | +* `getOnlyRow` provides no feedback on the error as we do not currently track table size information statically |
| 137 | + |
| 138 | + |
| 139 | +> Q. Which error situations are only partially expressible? Why, and what’s missing? |
| 140 | +* Two versions of `brownJellybeans` are implemented with tradeoffs on expressibility: |
| 141 | + * The first version takes a string column name and uses our more dynamic operations to select the column. |
| 142 | + This provides no feedback on the error but more closely matches the implementation in the benchmark. |
| 143 | + * The second version takes a function that selects the column and uses our more type-safe operations to select the |
| 144 | + column. This correctly localizes the error to the column selection. |
| 145 | + |
| 146 | +> Q. Which error situations’ expressibility is unknown? Why? |
| 147 | +None |
| 148 | + |
| 149 | +> Q. Which error situations can be expressed more precisely than in the benchmark? How? |
| 150 | +None |
| 151 | + |
| 152 | +> Q. Which error situations are prevented from being constructed? How? |
| 153 | +None |
| 154 | + |
| 155 | +> Q. For each error situation that is at least partially expressible, what is the quality of feedback to the programmer? |
| 156 | +* Malformed Tables |
| 157 | + * For missing schemas, rows, and cells they are represented by syntactic holes in the program. These are easily |
| 158 | + visible in the editor and can be filled in by the programmer. |
| 159 | + * For tables where the schema is the incorrect length static errors are added onto each row showing the type |
| 160 | + inconsistency between the schema type and the row type. |
| 161 | + * If extraneous columns are present, the error is localized to the column label and an error is placed |
| 162 | + * e.g. `favorite color is not part of expected labels: name, age`. |
| 163 | + * If there is a cell of the wrong type, the error is localized to the cell and an inconsistent type error is placed |
| 164 | + * e.g. `String inconsistent with expected type Int for label age` |
| 165 | + |
| 166 | +Note that in the following programs the errors are partially localized based off of the chosen explicit type |
| 167 | +application. Using different type-hole inference or choices for parametric type application would change the error |
| 168 | +localization and message. |
| 169 | + |
| 170 | +* `midFinal` |
| 171 | + * Localizes the error to the column selection `mid` in the editor. |
| 172 | + * Message: `Label mid not found in tuple's labels: name age quiz1 quiz2 midterm quiz3 quiz4 final` |
| 173 | +* `blackAndWhite` |
| 174 | + * Localizes the error to the column selection `black and white` in the editor. |
| 175 | + * Message: |
| 176 | +```Label `black and white` not found in tuple's labels: get_acne red black white green yellow brown orange pink purple``` |
| 177 | +* `pieCount` |
| 178 | + * Localizes the error to the column selection `true` and `get_count` in the editor.` |
| 179 | + * The error messages are similar to above |
| 180 | +* `brownAndGetAcne` |
| 181 | + * Localizes the error to the column selection `brown and get acne` in the editor. |
| 182 | + * The error messages are similar to above |
| 183 | +* `favoriteColor` |
| 184 | + * Localizes the error to the column selection `favorite color` in the editor. |
| 185 | + * The error message: `String is inconsistent with expected type Bool` |
| 186 | +* `brownJellybeans` |
| 187 | + * The first version provides no feedback on the error as it uses the string column name. |
| 188 | + * The second version localizes the error to the column selection, `color` with an error message similar to above. |
| 189 | +* `employee_to_department` |
| 190 | + * Localizes an error to the column selection `last_name` in the editor |
| 191 | + * Localizes another error to the tuple extension saying the resulting row's type is inconsistent since `last_name` is |
| 192 | + a `Int` but the expected type is `String` |
| 193 | + * The error message: `Label department not found in tuple's labels: name age department salary` |
| 194 | + |
| 195 | + |
| 196 | +> Q. For each error situation that is prevented from being constructed, what is the quality of feedback to the programmer? |
| 197 | +N/A |
0 commit comments