Make ListTable an instance of Prelude.Functor
#84
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.
This is a draft/proof of concept. Some things to point out:
The
ListContextthing isn't strictly necessary. We could move that intoInterpretation, or we could just have multipleTableinstances forListTablethat specialises the context. Or we could have dynamic dispatch inTableif we haveInterpretationcarry some kind of singleton.The implementation is a hacky mess. This wouldn't be the final code - there's plenty of tidying to do. In particular, Opaleye needs upstream changes to support running a subselect as an expression.
The implementation of
toColumnsinTable Expralways callsunnestand re-aggregation. This isn't necessary. In practice, I would have a second constructor forListTablewhich is the non-fmaped version which gives us a fast path.In terms of some other things I tried:
ListTable i o, whereiis the "input" to theListTable. The problem with this is withHList. If we haveHList Expr foo, what should we produce?ListTable foo foois an option, but that seems overly restrictive, as it doesn't let you build that field usingfmap. Maybe it can beforall i. Table (Context foo) i => ListTable i fooor something, but I didn't try that.