Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/potocpav/typed-serialization
Serialization withTtype Information
https://github.com/potocpav/typed-serialization
Last synced: 15 days ago
JSON representation
Serialization withTtype Information
- Host: GitHub
- URL: https://github.com/potocpav/typed-serialization
- Owner: potocpav
- Created: 2021-10-27T08:04:02.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-28T09:49:18.000Z (about 3 years ago)
- Last Synced: 2024-11-07T05:36:30.795Z (2 months ago)
- Language: Haskell
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Typed Serialization
The [library itself is here](src/TypedSerialization.hs), and [example use-case is here](app/Main.hs).
Everything can be run with `cabal run`.
This library allows us to defer type checking of expressions to run time. At run time, there is a separate "type-checking" step which validates the given expression before any data is processed. This gives us the guarantee that data processing itself can't fail, no matter the input.
This would be useful for value passing inside an algebra. Algebra needs a way to pass typed values around (green connections in the [Graph DSL proposal](https://scriveab.atlassian.net/wiki/spaces/EN/pages/3088646145/8+-+Graph+DSL)). TypedSerialization library allows us to work with values in validated graphs without worrying about any serialization failures.
This approach can be easily extended to also prove that values exist because they were set earlier in the flow. Haskell code then wouldn't need to [wrap values inside `Maybe`](https://github.com/scrive/kontrakcja/blob/master/backend/flow/src/Flow/Controller/Algebra.hs#L113-L118) and [use `fromJust` on them](https://github.com/scrive/kontrakcja/blob/master/backend/flow/src/Flow/Controller/Algebra.hs#L108-L109), as it currently does.
## Unresolved Questions
* Does this already exist somewhere?
* Can we get rid of some of the type parameters? Using this library as-is, the algebra would gain another two type parameters. `Flow e c l k s t` doesn't look good.
* Is there another way to transform types to values with `Eq`, perhaps supported by the compiler?