Contents
- Introducing newtypes
- Declaring new types
- Using our new types
- Revising
main
Video
- 22 minutes
In this lesson we introduce some new types. We use newtype
s that will help us distinguish at the type level between strings that represent inputs (password, username) and strings that represent errors.
We’d also like to keep a username and a password together as a User
value, so we write a product type called User
. We refactor the code we already have, write new functions that validate username inputs, and write a function that constructs a User
from the conjunction of a valid Username
and a valid Password
.