Fleece icon indicating copy to clipboard operation
Fleece copied to clipboard

Fable integration

Open gusty opened this issue 7 years ago • 5 comments

In theory, this library could be perfectly used in the Fable ecosystem.

Although it allows heavy use of SRTP, it also permits to manually specify a codec combinator, the same way ELM inspired Json libs do.

On top of that, the feature of specifying a single codec would also work without relying on SRTP overload, by specifying a codec for each field.

The last sample code in the readme https://github.com/mausch/Fleece#combinators illustrate this.

There shouldn't be any issue to use this in Fable.

I'm not sure what is required in order to by Fable ready, all I know is that there are no stoppers.

Is there anyone interested in take it there?

CC: @alfonsogarciacaro @wallymathieu

gusty avatar Nov 04 '18 21:11 gusty

I had a quick look at the code, if you don't depend on reflection it should work (there's indeed some reflection support in Fable but it's limited). SRTP should work and has been improved in Fable 2, if you find an edge case we can try to fix it in Fable. Though it's the fist time I see the GeneralizableValue attribute, not sure if it works in Fable.

If you're using Expecto for the tests I recommend just using some Mocha polyfills as Fable itself does, try to run them with Fable and see what fails.

BTW, there's already a similar JSON library for Fable, Thoth.Json. cc @mangelmaxime

alfonsogarciacaro avatar Nov 04 '18 21:11 alfonsogarciacaro

At the moment there is zero reflection code in this library.

The generalizable attribute in that example is a bit exotic, the same effect could be achieved by making it a function accepting () instead. I should update that, it looks more complicated than what really is.

We're not using Expecto here, we use Fuchu, which is actually the original project Expecto was based on. So probably we can run those tests with Fuchu as well.

I had a look a Thoth.Json, it seems to be a minimalistic combinator based library which could be seen as a subset of Fleece if you compare them.

On one side, having a simple library could be convenient. The idea of adding more features to Fleece is that it could integrate better with different libraries, being suitable for different scenarios.

Maybe we can join efforts at some point.

gusty avatar Nov 04 '18 22:11 gusty

I feel like I'm able to work in a flavor compatible with Fable. But I wonder is there any user having the possibility to use it in such scenario? So, we can test the design in a real project.

gusty avatar Jun 10 '20 05:06 gusty

This library uses Fuchu for tests. We could adjust Fuchu to run on both Fable and .net.

wallymathieu avatar Jun 10 '20 06:06 wallymathieu

IIRC Expecto uses the same API as Fuchu. What we usually do in that case is map the test declaration so they use a JS test runner like Mocha when compiled by Fable. See this and this.

alfonsogarciacaro avatar Jun 11 '20 01:06 alfonsogarciacaro