New workflow again, Typesafe data source implementation #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Remove
|>
and turn$>
into the left-associative%>
.Massively increase type safety. A very large class of invalid BokeHS plots are now impossible to construct. In practice, this guarantees the validity of the Haskell AST at compile time (though perhaps errors can happen in serialization to JSON). Specifically,
TypeLits
are used to refer to columns so that their existence in the data source is guaranteed. The downside of this is the addition of typelevel boilerplate, though I try and keep this to a minimum.To get around the lack of dependent types, we have to refer to columns as
Key :: Key "Column"
. I can think of a few ways around this using type application or Template Haskell, though it doesn't seem too bad as is.The more significant piece of boilerplate is the need of a
HasColumn row name value | row name -> value
instance, indicating that something of typevalue
can be extracted from row typerow
, indexed by symbolname
. Again, there are a variety of ways to remove the boilerplate here that I'm experimenting with. I include the simplest one, which is to automatically provide an overlappable instance for all record types usingGHC.Records.HasField
.