-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
When computing statistics over collections of anonymous records, it would be helpful to have a way to drop a field from a record without knowing the concrete row-type at compile time.
Say I wanted to compute group statistics: [Record I rs] -> (MonoidalMap k (Record (Mean 'Product' Count) rs'. If I know rs' then I can just specify what the row should be and use proejct. But, if i'd like to keep such a combinator around (I do), then I'd rather have::
groupBy' :: Field n -> (forall x. f x -> g x) -> Record f rs -> (f kn, Record g (DropField (n '=: kn) rs))
groupByField :: Field n -> (forall x. f x -> g x) -> t (Record f rs) -> MonoidalMap kn (Record g (DropField (n '=: kn) rs)A cursory attempt at implementing DropField using first-class-families to filter the list yields a not unexpected occurrence of "the impossible":
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.4.5:
Unexpected KnownFields constraint with arguments:
Type
Eval
(If
(Eval
(Not (TyEqImpl ("foo" ':= kv_akut[tau:0]) ("foo" ':= Text))))
((':) ("foo" ':= Text)
<$> Filter
(Not <=< TyEq ("foo" ':= kv_akut[tau:0]))
'[ "bar" ':= Text, "date" ':= Day, "time" ':= Integer,
])
(Filter
(Not <=< TyEq ("foo" ':= kv_akut[tau:0]))
'[ "bar" ':= Text, "date" ':= Day, "time" ':= Integer]))
What's the right way to implement it?
Metadata
Metadata
Assignees
Labels
No labels