Dhall-haskell: Dhall format of plain record produces operator (/\) merge

Created on 8 Sep 2020  Â·  8Comments  Â·  Source: dhall-lang/dhall-haskell

This must be the most surprising dhall format I have encountered so far ;-)

  { kafka.keystore.p12 = "fgfg"
  , kafka.properties = "ds="
  , kafka.truststore.jks = "L3UzKzdRQUdsFBQ9"
  }

->

{ kafka =
      { keystore.p12 = "fgfg" }
    ∧ { properties = "ds=" }
    ∧ { truststore.jks = "L3UzKzdRQUdsFBQ9" }
}

bug formatting

Most helpful comment

@sjakobi: Also, my plan is to resugar as the first expected output you suggested:

{ kafka.keystore.p12 = "fgfg"
, kafka.properties = "ds="
, kafka.truststore.jks = "L3UzKzdRQUdsFBQ9"
}

… since that preserves the user's original intention. If the user wanted the latter expected output they can always explicitly author the code that way and the formatter would preserve that, too.

All 8 comments

Nice catch! :+1:

The expected output is

{ kafka.keystore.p12 = "fgfg"
, kafka.properties = "ds="
, kafka.truststore.jks = "L3UzKzdRQUdsFBQ9"
}

right?!

Anything less intrusive would do ;-)

I first believe only dhall lint would go that far but I was quite surprised even dhall format was doing this kind of transformation but yep this is the expected output (at least from my point of view).

Actually

{ kafka =
    { keystore.p12 = "fgfg"
    , properties = "ds="
    , truststore.jks = "L3UzKzdRQUdsFBQ9"
    }
}

would also seem reasonable to me. I think that might have been the intention of the current formatting code, but the explicit /\s look like a bug.

Sure I would not mind the second option. I have no real preference.

Yeah, this is an unintended consequence of how we desugar chained accessors at parse time. I believe the way we can fix this is the same way we handle other syntactic sugar: "resugar" at pretty-printing time.

@sjakobi: Also, my plan is to resugar as the first expected output you suggested:

{ kafka.keystore.p12 = "fgfg"
, kafka.properties = "ds="
, kafka.truststore.jks = "L3UzKzdRQUdsFBQ9"
}

… since that preserves the user's original intention. If the user wanted the latter expected output they can always explicitly author the code that way and the formatter would preserve that, too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SiriusStarr picture SiriusStarr  Â·  5Comments

Profpatsch picture Profpatsch  Â·  4Comments

jwoudenberg picture jwoudenberg  Â·  6Comments

DrSensor picture DrSensor  Â·  6Comments

SiriusStarr picture SiriusStarr  Â·  5Comments