26 lines
547 B
Markdown
26 lines
547 B
Markdown
|
|
# 09-haskell-newtype
|
||
|
|
|
||
|
|
This example shows intermediate Haskell domain modeling with `newtype` and smart constructors.
|
||
|
|
|
||
|
|
It includes:
|
||
|
|
|
||
|
|
- `newtype` wrappers for `UserName` and `Email`,
|
||
|
|
- smart constructors that validate raw input,
|
||
|
|
- an explicit `Either String` error path, and
|
||
|
|
- a test suite run by `nix flake check`.
|
||
|
|
|
||
|
|
Useful commands:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
nix develop
|
||
|
|
cabal run
|
||
|
|
cabal run -- learner learner@example.com
|
||
|
|
cabal test
|
||
|
|
|
||
|
|
nix build
|
||
|
|
./result/bin/mini-registration learner learner@example.com
|
||
|
|
|
||
|
|
nix run . -- learner learner@example.com
|
||
|
|
nix flake check
|
||
|
|
```
|