Last active
March 30, 2020 10:59
-
-
Save jchia/43c3adee41d522d03c546142bb79b651 to your computer and use it in GitHub Desktop.
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
data Config = Config { x :: Int, y :: Int } | |
defaultConfig :: Config | |
data Options' a = OptionsA { queue :: Text } | |
| OptionsB { config :: a, queue :: Text, a :: Text, b :: Maybe Int } | |
| OptionsC { config :: a, queue :: Text, c :: Int, d :: Word8 } | |
| OptionsD { config :: a, queue :: Text, c :: [Word8], d :: Bool } | |
using Options1 = Options' (Maybe Text) | |
using Options2 = Options' Config | |
readConfig :: MonadIO m => Maybe Text -> m Config | |
readConfig Nothing = pure defaultConfig | |
readConfig (Just fp) = ... -- reads and parses Config from a file with path fp. | |
-- What's a non-boilerplatey way of defining convertOptions1ToOptions2, avoiding | |
-- exhaustively defining for individual data constructors? | |
convertOptions1ToOptions2 :: MonadIO m Options1 -> m Options2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment