parseAndCacheYxConfig :: FilePath -> FilePath -> IO ProjectConfig
parseAndCacheYxConfig yxConfig out = parseProjectConfig yxConfig >>= \case
    Left e -> throwIO e
    Right r -> do
        createDirectoryIfMissing True (FilePath.takeDirectory out)
        -- TODO: Use efficient binary serialization. Should we assume
        --       portability? I hope not, but some people may use git clone
        --       inside a Dropbox. Don't ask for details, please, just think
        --       about how to handle such (pathological) cases.
        r <$ Lazy.ByteString.writeFile out (Aeson.encode r)

    -- TODO: We should check that there is at least one environment section in
    --       the configuration file and that there is exactly one with
    --       "is-default: True".

-- | Create initial version of project configuration file.
--
-- *TODO:*
--
-- * When /Stack/ is detected, then we need to add stack wrappers in to the configuration.
--
-- * When non-standard /Stack configuration file/ is found, then @STACK_YAML@
--   should be defined.
parseAndCacheYxConfig :: FilePath -> FilePath -> IO ProjectConfig
parseAndCacheYxConfig yxConfig out = parseProjectConfig yxConfig >>= \case
    Left e -> throwIO e
    Right r -> do
        createDirectoryIfMissing True (FilePath.takeDirectory out)
        -- TODO: Use efficient binary serialization. Should we assume
        --       portability? I hope not, but some people may use git clone
        --       inside a Dropbox. Don't ask for details, please, just think
        --       about how to handle such (pathological) cases.
        r <$ Lazy.ByteString.writeFile out (Aeson.encode r)

    -- TODO: We should check that there is at least one environment section in
    --       the configuration file and that there is exactly one with
    --       "is-default: True".

-- | Create initial version of project configuration file.
--
-- *TODO:*
--
-- * When /Stack/ is detected, then we need to add stack wrappers in to the configuration.
--
-- * When non-standard /Stack configuration file/ is found, then @STACK_YAML@
--   should be defined.
parseAndCacheYxConfig yxConfig out = parseProjectConfig yxConfig >>= \case
    Left e -> throwIO e
    Right r -> do
        createDirectoryIfMissing True (FilePath.takeDirectory out)
        -- TODO: Use efficient binary serialization. Should we assume
        --       portability? I hope not, but some people may use git clone
        --       inside a Dropbox. Don't ask for details, please, just think
        --       about how to handle such (pathological) cases.
        r <$ Lazy.ByteString.writeFile out (Aeson.encode r)

    -- TODO: We should check that there is at least one environment section in
    --       the configuration file and that there is exactly one with
    --       "is-default: True".

-- | Create initial version of project configuration file.
--
-- *TODO:*
--
-- * When /Stack/ is detected, then we need to add stack wrappers in to the configuration.
--
-- * When non-standard /Stack configuration file/ is found, then @STACK_YAML@
--   should be defined.