merijn / validated-literals

Compile-time checking for partial smart-constructors
BSD 3-Clause "New" or "Revised" License
20 stars 3 forks source link

Make ValidLiterals safer and more ready for use #1

Closed lamefun closed 6 years ago

lamefun commented 8 years ago

Also, does FromLiteral actually need more than one l per a? Should I remove DefaultLiteralType and simply add | a -> l dependency directly to FromLiteral? Here's the simpler version.

merijn commented 8 years ago

The ADT instead of the warning might be an improvement, but I'm not sure what the benefit of switching to FunctionalDependencies and DefaultLiteralType is supposed to be?

lamefun commented 8 years ago

Here's the description: https://github.com/merijn/validated-literals/pull/1/commits/ffb2744999bde430cd05effd935257d83ac942d9#diff-c1c013433d9f6600411c8d0be3daa99bR110

The idea is that it makes it so that in constructs like $$(valid 3) the proper literal type can be automatically determined in cases where the result type is specified or deduced by the compiler from the context, so that functions such as validInteger are needed less frequently.