Custom Data Type coverage in current exercises
- Langage dominant
- Haskell
- Étoiles
- 529
- Forks
- 201
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
**TL;DR:** Basically I'm looking for simple data modelling exercises that involve recursive custom data types (not general-purpose ones from the standard library, like `Data.List` or `Data.Tree`) -- they may however have type parameters -- with multiple constructors and possibly multiple constructor parameters.
---
**The long version:** I want to create an overview of what coverage the concept of custom data types our current exercises has got. The purpose is to propose porting or creating exercises that cover the missing areas.
I went over all Haskell exercises using the following query:
exercism/haskell/exercises $ ack '^data' -A 10 --type=haskell --ignore-dir=examples --ignore-dir=test
and characterised their use of custom data types:
| Exercise | | Properties / Purpose |
| ------------------------ | -- | ------------------------------------------------------- |
| `space-age` | 1 | Enum | `Mercury / Venus / ...` |
| `resistor-colors` | 2 | Enum | `Black / Brown / ...` |
| `grade-school` | 2 | newtype | ... |
| `perfect-numbers` | 2 | Enum | `Deficient / Perfect / Abundant` |
| `nucleotide-count` | 2 | Enum | `A / C / G / T` |
| `complex-numbers` | 3 | Product, single *type* parameter | `Complex a a` |
| `triangle` | 3 | Enum | `Equilateral / Isosceles / ...` |
| `kindergarten-garden` | 3 | Enum | `Clover / Grass / Radishes / Violets` |
| `robot-simulator` | 3 | Enum | `North / South / East / West` |
| `dnd-character` | 3 | Records | `Character { name, strength, ... }` |
| `simple-linked-list` | 4 | List, recursive | `Nil / Cons (List a)` |
| `all-your-base` | 4 | Enum, error handling, single parameter | `InvalidInputBase / ... / InvalidDigit a` |
| `meetup` | 4 | Enum, uses Data.Time.Calendar | `Monday / Tuesday / ...` |
| `largest-series-product` | 4 | Enum, error handling | `InvalidSpan / InvalidDigit` |
| `matrix` | 4 | Records | `Matrix { cells, rows, cols }` |
| `clock` | 4 | newtype | ... |
| `allergies` | 4 | Enum | `Eggs / Peanuts / ...` |
| `binary-search-tree` | 5 | Binary tree, recursive | ... |
| `custom-set` | 5 | Binary tree or list, recursive | ... |
| `linked-list` | 6 | Binary tree (heh), recursive, uses concurrency | ... |
| `sublist` | 6 | Enum | `Equal / Sublist / Superlist / Unequal` |
| `robot-name` | 6 | newtype, uses concurrency | ... |
| `zebra-puzzle` | 7 | Enum | `Englishman / ...` etc. |
| `bowling` | 7 | Enum, error handling, records | `IncompleteGame / InvalidRoll { rollIndex, rollValue }` |
| `connect` | 8 | Enum | `Mark / Cross` |
| `lens-person` | 9 | Nested records, lenses | `Person`, `Name`, `Born`, `Address` |
| `go-counting` | 9 | Enum | `Black / White` |
| `zipper` | 10 | Binary tree, recursive, tree zipper | ... |
| `forth` | 10 | Enum or AST, error handling, single parameter | `DivisionByZero / ... / UnknownWord Text` |
I then summarized this as the following categories:
- Data type is an **enum**, e.g. `space-age` (`Mercury`, `Venus` etc.)
- Data type has a constructor with a **parameter**, e.g. `all-your-base` (`InvalidDigit a`, etc.)
- Data type has a constructor with **two parameters**, i.e. `complex-number` (`Complex a a`)
- Data type is a **record** (multiple named parameters), e.g. `dnd-character` (`data Character = Character { ... }`)
- Data type has **nested records**, i.e. `lens-person` (10)
- Data type has a **type parameter**, e.g. `all-your-base`, `complex-number` (`data Error a = ...`, `data Complex a = ...`)
- Data type is a **custom error type**, e.g. `all-your-base` (4), `largest-series-product` (4), `bowling` (7), `forth` (10)
- Data type is a **list**, i.e. (`simple-linked-list`)
- Data type is a **binary tree**, i.e. `binary-search-tree`, `custom-set`, `linked-list`, `zipper`
Without being scientific, I keep a number of factors in my head when considering whether an exercise is a bad fit for the core track or as an early side exercise: Too mathy, too difficult, too many subjects covered at once, re-implements standard library, refactoring exercise, ...
General-purpose lists don't go under "custom data types"; there is no standard-library binary tree, but it's covered plentifully already; in particular, `binary-search-tree` is not too difficult and covers just one thing. Rose trees (`Data.Tree`) are addressed in exercism/problem-specifications#1388 in a way that leaves room for both a custom data type implementation and a recommendation to base it on `Data.Tree` instead.
So what I'd like are exercises that cover custom data types that aren't just enums, aren't just an error type, and aren't just single-constructor records, which we've covered pretty well already.
Here are some suggestions that new exercises that focus on custom data types could have:
- Data type that isn't error-handling with multiple constructors
- Data type that isn't error-handling with multiple constructor parameters
- Data type that isn't error-handling with one or more type parameters
- Data type that isn't re-implementation (list, binary tree) with recursive constructors
I remember an exercise from university on modelling certain types of acyclic, organic chemical bonds:
data Bond = C Bond Bond Bond Bond | H
So basically I'm looking for **easy** data modelling exercises that involve (possibly mutually) recursive custom data types (not general-purpose ones from the standard library, like `Data.List` or `Data.Tree`) -- they may however have type parameters -- with multiple constructors and possibly multiple constructor parameters.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.