Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What if my encoder/decoder/codec depends on some configuration options, am I forced to manually wire up? #145

Open
DamianReeves opened this issue Mar 20, 2024 · 1 comment
Labels

Comments

@DamianReeves
Copy link

DamianReeves commented Mar 20, 2024

I have types that must target multiple versions of a target JSON format, and I am wondering if I can use Fleece without being forced to drop down to using combinators to manually wire things together.

Lets say I have the following:

type Name = Name of Parts: string list
   member ToJson (options:MorphirJsonFormatOptions) = failwith "TODO: encode using options"
and MorphirJsonFormatOptions =
| Classic of Version:int
| NextGen of NextGenVersionOptions
and NextGenVersionOptions =  {Version:Version ; NameEncodingMode: NameEncodingMode}
and Version = Version of Major:int * Minor:int * Patch:int
and NameEncodingMode =
| ArrayStyle
| SnakeCasedSymbol

Are there any recommendations how I can still benefit from the SRTP resolution?

@wallymathieu
Copy link
Member

I think this question is quite interesting. The question about how an API should be able to decode/encode different versions with a sort of ambient context such as options that you want to thread into the codecs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants