Exercises part 2
module Tutorial.DataTypes.Exercises2
-
Implement an equality test for
Title
(you can use the equality operator(==)
for comparing twoString
s):total eqTitle : Title -> Title -> Bool
-
For
Title
, implement a simple test to check, whether a custom title is being used:total isOther : Title -> Bool
-
Given our simple
Credentials
type, there are three ways for authentication to fail:- An unknown username was used.
- The password given does not match the one associated with the username.
- An invalid key was used.
Encapsulate these three possibilities in a sum type called
LoginError
, but make sure not to disclose any confidential information: An invalid username should be stored in the corresponding error value, but an invalid password or key should not. -
Implement function
showError : LoginError -> String
, which can be used to display an error message to the user who unsuccessfully tried to login into our web application.