Architecture for 2.0 #220
Replies: 3 comments 3 replies
-
It's kind of a /nitpick |
Beta Was this translation helpful? Give feedback.
-
Possible hybrid option: Keep the module augmentation but have empty Schemables defined for every typeclass i.e. DecoderSchemable, EncoderSchemable. We can then write a SchemableLambda to abstract over all the FooSchemables and use a single interpreter / schema definition |
Beta Was this translation helpful? Give feedback.
-
Amendment: base type declarations like And if we're able to write that dynamic requirements schema, it should pair quite nicely. This will allow us to add derivation specific combinators / helpers |
Beta Was this translation helpful? Give feedback.
-
This is a discussion for all the changes related to the library's architecture for version 2.0.
fp-ts/schema
The original intention for 2.0 was to replace the Schemable system with the Provider system in fp-ts/schema. The Schemable system is isomorphic to the Provider system in that they contain the same amount of functionality / information. The difference between the two is that the Provider system relies on symbolic keys existing in a Map, which means that all instances must be generated unsafely. Unlike this, the Schemable system is type safe and all errors are captured in the type system.
All Schemable instances (Decoder, etc) will match in structure to that of fp-ts/schema, and not rely on Schemable in io-ts. For example, Decoder will return a These with DecodeErrors compatible with fp-ts/schema DecodeErrors.
Additionally it might be possible to write a zero'th order schemable typeclass for fp-ts/schema's AST, which would make complete interop possible.
Schemables
Symbol("string")
, which is a typesafe alternative to fp-ts/schema'sSymbol.for
inside a nested Map.With
s) will be renamed to lowercase without the With, and will be classified as Schemables../instances/InstanceName.ts
.src/schemables/primitive
Schemata API
src/schemata
will largely not change, and will still be exported fromsrc/schemata.ts
.src/schemata.ts
will be exported as flat Schamata from their respective files. I.e.Date.dateString()
will turn intoDateString()
.Int()
will stayInt()
.export * from
.Peer Dependencies
Schemata-ts version 2.0 will list fp-ts/core, fp-ts/data, and fp-ts/schema as peer dependencies, and the library will be reworked to use the new APIs from the fp-ts organization.
Beta Was this translation helpful? Give feedback.
All reactions