Example:
module Main (main) where import qualified Env import Numeric.Natural loadConfig :: IO Natural loadConfig = Env.parse id $ Env.var Env.auto "NAT" $ Env.def 1 main :: IO () main = print =<< loadConfig
Expected result:
% stack exec example 1 % NAT=2 stack exec example 2 % NAT=-1 stack exec example <Some error about how read of NAT failed on "-1" for Natural>
Actual result
% stack exec example 1 % NAT=2 stack exec example 2 % NAT=-1 stack exec example 1
It seems having a def set will use that if the parser (in this case auto) fails, instead of failing the overall parse.
In other words, Unset and Invalid should be two different things (I believe you've already got this information in your Error type), and def should only override an Unset error, not Invalid.