Git Product home page Git Product logo

Comments (7)

gusty avatar gusty commented on May 28, 2024 2

Fleece should handle recursive types without any problem when using implicit codecs (overloads) which is the case here.

This failure seems to be due to a bug that was introduced recently.

I'll have a look and see how can it be solved.

from falanx.

7sharp9 avatar 7sharp9 commented on May 28, 2024

As single self referencing type fails:

[<CLIMutable>]
type NestedTestAllTypes =
    { mutable child : NestedTestAllTypes option }

    static member JsonObjCodec =
        fun child  -> { child = child}
        |> Fleece.Newtonsoft.withFields
        |> Fleece.Newtonsoft.jfieldOpt ("child") (fun x -> x.child) 

from falanx.

7sharp9 avatar 7sharp9 commented on May 28, 2024

falanx_test.fs(800, 12): [FS0001] Type mismatch. Expecting a:

(IReadOnlyDictionary<string,JsonValue> -> Result<(TestAllTypes option -> NestedTestAllTypes),DecodeError>) * (NestedTestAllTypes -> IReadOnlyDictionary<string,JsonValue>) -> ConcreteCodec<KeyValuePair<string,JToken> list,KeyValuePair<string,JToken> list,NestedTestAllTypes,NestedTestAllTypes>

but given a:

SplitCodec<IReadOnlyDictionary<string,JsonValue>,(TestAllTypes option -> NestedTestAllTypes),NestedTestAllTypes> -> (IReadOnlyDictionary<string,JsonValue> -> Result<NestedTestAllTypes,DecodeError>) * (NestedTestAllTypes -> IReadOnlyDictionary<string,JsonValue>)

The type:

ConcreteCodec<KeyValuePair<string,JToken> list,KeyValuePair<string,JToken> list,NestedTestAllTypes,NestedTestAllTypes>

does not match the type:

(IReadOnlyDictionary<string,JsonValue> -> Result<NestedTestAllTypes,DecodeError>) * (NestedTestAllTypes -> IReadOnlyDictionary<string,JsonValue>)

from falanx.

7sharp9 avatar 7sharp9 commented on May 28, 2024

@gusty The solution was to use the ConcreteCodec parts and depreciate the use of `jfieldOpt etc?

from falanx.

gusty avatar gusty commented on May 28, 2024

Yes.

To add more context: the problem is that ConcreteCodecwas introduced as the way to define codecs, while the jfield family of functions were kept as backward compatible, but this caused a problem with recursive definitions as both overloads exists and the priority is given to the ConcreteCodec.

So, an easy fix is:

  • in Fleece rename the JsonObjCodec method
  • in Falanx also change that to that new name

A better but more complicated fix is what you say: use in Falanx ConcreteCodec which will be the supported way moving forward.

from falanx.

7sharp9 avatar 7sharp9 commented on May 28, 2024

Would ConcreteCodec alleviate the issue with tuple encoding?

from falanx.

gusty avatar gusty commented on May 28, 2024

Yes, ConcreteCodec does not suffer the infinite recursion, as it's the default overload.

from falanx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.