dhall-lang / dhall-to-cabal

Compile Dhall expressions to Cabal files
MIT License
100 stars 19 forks source link

Use toMap for defining components? #178

Open ocharles opened 5 years ago

ocharles commented 5 years ago

It feels like the new toMap keyword could be nicer for defining the components of a library. The keys are component names and the values are their definitions. Anyone any thoughts on this?

quasicomputational commented 5 years ago

I think I'm +1 on this, since using toMap will give you some static assurance about component name collisions, besides the nicer syntax. (We could even take that assurance further with, e.g., a single named-components : List { name: Text, component : < Test | Library | ... > } field!)

ocharles commented 5 years ago

will give you some static assurance about component name collisions, besides the nicer syntax

Note that this is in some sense "opt-in" - you don't have to use toMap, you just have to supply a List { mapKey : Text, mapValue : Executable } (for the executables section). This means it's still possible to supply duplicates, and we should decide what to do in that case (I think just error out).

a single named-components field!

Should we do this at the same time? I do like it.

quasicomputational commented 5 years ago

Yeah, it's opt-in - but, since dhall-to-cabal is opt-in anyway, I think nudging people towards safer practice is sensible enough.

On named-components: OK, let's do it!

ocharles commented 5 years ago

{ named-components : Map Text Component, library : Optional Library } ?