Really cool stuff! One way that I've blended io-ts and monole-ts together is the use of the .is function in io-ts to replicate pattern matching in Haskell or OCaml. That helps especially in Prisms. So, for example...
io-ts
monole-ts
.is
new Prism<string | integer, string>(a => t.string.is(a) ? some(a) : none, s => s)
Here, is is a primitive type of pattern matching that does the job both at runtime and at compile time (this is compile safe in typescript).
is
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Really cool stuff! One way that I've blended
io-ts
andmonole-ts
together is the use of the.is
function inio-ts
to replicate pattern matching in Haskell or OCaml. That helps especially in Prisms. So, for example...Here,
is
is a primitive type of pattern matching that does the job both at runtime and at compile time (this is compile safe in typescript).