Created
May 11, 2019 11:14
-
-
Save etorreborre/f07d0321ccfa058a0f13ff8b7fbda1f3 to your computer and use it in GitHub Desktop.
nested data types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data Company = Company { | |
| companyName :: Text | |
| , departments :: [Department] | |
| } deriving (Eq, Show) | |
| data Department = Department { | |
| departmentName :: Text | |
| , employees :: [Employee] | |
| } deriving (Eq, Show) | |
| data Employee = Employee { | |
| employeeName :: Text | |
| , employeeStatus :: EmployeeStatus | |
| , salary :: Int | |
| , bonus :: Maybe Int | |
| } deriving (Eq, Show) | |
| -- | Note that this is an ADT with several constructors | |
| data EmployeeStatus = | |
| Permanent | |
| | Temporary Int -- number of days | |
| deriving (Eq, Show) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment