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
ListContext
thing isn't strictly necessary. We could move that intoInterpretation
, or we could just have multipleTable
instances forListTable
that specialises the context. Or we could have dynamic dispatch inTable
if we haveInterpretation
carry 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
toColumns
inTable Expr
always callsunnest
and re-aggregation. This isn't necessary. In practice, I would have a second constructor forListTable
which is the non-fmap
ed version which gives us a fast path.In terms of some other things I tried:
ListTable i o
, wherei
is the "input" to theListTable
. The problem with this is withHList
. If we haveHList Expr foo
, what should we produce?ListTable foo foo
is 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 foo
or something, but I didn't try that.