This gist demonstrates a type-safe bridge between Haskell and PureScript in which
you write a config/schema
, config/rpc
file (kinda like yesod's config/routes
)
and some template Haskell will output a .hs and .purs
file via the templates/Schema.hs
/templates/Schema.purs
.
This also demonstrates migrations between schemas on a per-type basis. Similar to e.g. acid-state, when a type changes, we create a new type that is a copy of the old plus/minus our change and a version bump. Any types using the new type will define a migration from the old to the new. This way, old clients can talk to new servers. Additionally, older schema JSON saved in the database/redis can be read by newer servers.
Old types are marked as deprecated, which helps the developer to avoid using those old types in the codebase.
Separately, I use GenUnchecked from the genvalidity package to encode/decode from/to Haskell/PureScript with randomly generated inputs.