Open smarwei opened 1 year ago
Yeah, this change in behavior was intentional and is due to:
https://github.com/dhall-lang/dhall-haskell/pull/1696
The basic idea is that InterpretOptions
are no longer applied globally but are now specified on a type-by-type basis, so the way you would fix your example is to do this:
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Dhall
import qualified Data.Text
data GitRepo
= GitRepo
{ _host :: Text
, _repo :: Text
} deriving (Generic, Show)
data BoxConfig
= BoxConfig
{ _userName :: Text
, _dotfilesRepo :: GitRepo
} deriving (Generic, Show)
instance FromDhall GitRepo where
autoWith =
genericAutoWithInputNormalizer defaultInterpretOptions
{ fieldModifier = Data.Text.dropWhile (== '_') }
instance FromDhall BoxConfig where
autoWith =
genericAutoWithInputNormalizer defaultInterpretOptions
{ fieldModifier = Data.Text.dropWhile (== '_') }
main :: IO ()
main = do
x <- input auto "./config.dhall"
print (x :: BoxConfig)
It seems like I stumbled upon a bug, which was already fixed in #33 a few years ago. I slightly adjusted the old example:
Prepending _ only works for top-level attributes.