farlee2121 / FsSpec

FsSpec represents value constraints as data to reuse one constraint declaration for validation, data generation, error explanation, and more.
25 stars 0 forks source link

Question: fable compatible? #3

Open OnurGumus opened 2 years ago

OnurGumus commented 2 years ago

Is this at least partially fable compatible?

farlee2121 commented 2 years ago

Hmm. I haven't tried using it with fable yet. Looking at the compatability guide. I would guess it is not very compatible because

It's not possible to type test against interfaces or generic types.

The core FsSpec library only depends on Fsharp.Core and a few basic types from the BCL (IComparable<T>, IEnumerable, EqualityComparer<T>). The problem comes from the use of type tests and reflection to check implementation of those interfaces.

farlee2121 commented 2 years ago

Hmm, actually most of the type testing is in the data generation library. I think validation (thus explanation and formatting) might work for all the constraints except length. We might be able to change the implementation of length validation to accommodate Fable too

OnurGumus commented 2 years ago

Yes tests don't have to be fable compatible.

farlee2121 commented 2 years ago

Not tests as in automated tests but type tests as in this example

| :? System.Collections.IEnumerable as coll ->

These are part of the production code and are not supported by fable