kowainik / tomland

🏝 Bidirectional TOML serialization
https://kowainik.github.io/posts/2019-01-14-tomland
Mozilla Public License 2.0
120 stars 39 forks source link

DerivingVia for Generic table codecs #272

Closed chshersh closed 4 years ago

chshersh commented 4 years ago

I've tried to use fancy tricks for table codecs with generics. You can find my commented code here:

https://github.com/kowainik/tomland/blob/536a5e6ffb148d0dd4e4c4b120913a6744097676/src/Toml/Codec/Generic.hs#L406-L449

It wasn't possible to implement this feature back then. But thanks to @vrom911 nice work on simplifying the Codec type, I think we should be able to implement that feature again.

vrom911 commented 4 years ago

Currently, I am getting

    • Couldn't match type ‘TomlTable Address’ with ‘Address’
        arising from the coercion of the method ‘hasCodec’
          from type ‘Toml.Key -> TomlCodec (TomlTable Address)’
            to type ‘Toml.Key -> TomlCodec Address’
    • When deriving the instance for (HasCodec Address)
    |
182 |       deriving HasCodec via (TomlTable Address)
    |    

With the example from docs. I don't really know how to solve this issue. Do you have any ideas, @chshersh ?

(link to the branch)

chshersh commented 4 years ago

@vrom911 Ah, sh*t, here we go again. The error is different, but it doesn't tell me how to solve the issue. Well, I guess not in this release...

chshersh commented 4 years ago

I've asked on SO:

chshersh commented 4 years ago

Should be possible to do after #311 :slightly_smiling_face: