-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerson.hs
22 lines (19 loc) · 837 Bytes
/
Person.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Person where
import Core
import List (Chars)
-- Suppose we have a data structure to represent a person. The person data structure has these attributes:
-- * Age: positive integer
-- * First Name: non-empty string that starts with a capital letter and is followed by zero or more lower-case letters
-- * Surname: string that starts with a capital letter and is followed by 5 or more lower-case letters
-- * Smoker: character that must be 'y' or 'n' that maps to a boolean
-- * Phone: string of digits, dots or hyphens but must start with a digit and end with a hash (#)
data Person
= Person
Int -- age
Chars -- first name
Chars -- surname
Bool -- smoker
Chars -- phone number
deriving stock (Eq, Show)