I'm using Dhall to accept user configurations. Some field are compulsory while the others are optional, whose default values should be used when left unspecified by the user. This is what I currently have:
override :: FilePath -- user
-> FilePath -- default
-> IO Config
override user def = parseConfig $ def ++ " // " ++ user
finalConfig :: IO Config
finalConfig = do user <- getUserConfig
def <- getDataFileName "defaults.dhall"
return (user `override` defaults)
Clearly concatenating file paths and inserting the // operator is dirty enough. I wonder if there is a more elegant approach to this.
So this is not something that is ergonomic to do using the current Haskell API, but I just put up a pull request to add a few new utilities that would make this easier. Once that is merged and released, you'd be able to interpret and decode an
Exprinstead ofTextso that you don't have to work with raw strings.