Created
October 1, 2017 18:00
-
-
Save ninjazoete/6c3013c6b351b90b7be19077c007d97f to your computer and use it in GitHub Desktop.
(Haskell-Book-Chp-11-Task-1)
This file contains 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
-- Exercise given data types | |
data OperatingSystem = GnuPlusLinux | |
| OpenBSDPlusNevermindJustBSDStill | |
| Mac | |
| Windows | |
deriving (Eq, Show, Enum) | |
data ProgrammingLanguage = Haskell | |
| Agda | |
| Idris | |
| PureScript | |
deriving (Eq, Show, Enum) | |
data Programmer = Programmer { os :: OperatingSystem | |
, lang :: ProgrammingLanguage } | |
deriving (Eq, Show) | |
allOperatingSystem :: [OperatingSystem] | |
allOperatingSystem = [ GnuPlusLinux | |
, OpenBSDPlusNevermindJustBSDStill | |
, Mac | |
, Windows | |
] | |
allLanguages :: [ProgrammingLanguage] | |
allLanguages = [Haskell, Agda, Idris, PureScript] | |
-- Task: | |
-- Write allProgrammers functions which will return all possible Programmers | |
-- that are working on each OperatingSystem and in each Programming Language. | |
-- Todays Solution | |
allProgrammers :: [Programmer] | |
allProgrammers = (uncurry Programmer) <$> ((,) <$> allOperatingSystem <*> allLanguages) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment