roman / Haskell-etc

Declarative configuration spec for Haskell projects
MIT License
47 stars 7 forks source link

Add template haskell function to parse config spec #47

Closed roman closed 6 years ago

roman commented 6 years ago

Using Template Haskell, provide a function that can read a JSON FilePath, parse the config spec and lift the config spec in the code.

This utility will allow users to validate the config spec at compile time, and not at runtime.

ketzacoatl commented 6 years ago

This would be hugely helpful for newbs! I ran into a few of these similar situations where I had a simple error/mistake in the config spec but did not get the error message until runtime.

Specifically, I've seen both:

ᐅ app say_hi
app: InvalidConfiguration Nothing "Error in $['etc/entries'].env.cli.commands[1]: expected Cmd (say_hi), encountered String"

and:

ᐅ app say_hi
app: CommandKeyMissing

44 partially addresses the last one, but I believe a check on the commands might catch that too.

For the first one, I have both mispelled commands and had tried to access keys in a command that wasn't included in the key's entry in the spec.