Closed jwoudenberg closed 5 years ago
I solved my problem by writing a custom implementation of match
for my use case, which turned out to be pretty straight forward. Curious if I could have done this in a better way, but I'm not longer blocked. Going to close this issue.
I have a co-record with named fields
CoRec ElField xs
. I also have an encoder typenewtype Encoder a = Encoder (a -> Encoded)
.I'd like to match this with a record containing encoders for each named field
Rec (WrappedField Encoder) xs
.WrappedField
is a variation onElField
I wrote because it's not possible to write the compositionElField .: Encoder
:I'm stuck in trying to get
match
to run the co-record against the encoders in the record, becausematch
takes aCoRec Identity xs
.I tried massaging my record and co-record types to ones that
match
will accept. This basically comes down to dropping their fields, but this changes the kind ofxs
from[(Symbol, Type)]
to[*]
:So far this type checks, but I can't figure out how to write implementations
mkHandlers
anddropLabels
. Take this naive implementation ofdropLabels
:This fails to compile because I don't know the type of the variant of the sum type I'm constructing.
I don't know a ton about compiler proofs, but think this is maybe a place where one is warranted? I was hoping I might get some feedback on this approach before committing to that rabbit hole. Can this approach even work and/or am I making things unnecessarily hard for myself by going this way? Would super appreciate any help!