I’ve been using untagged-union on FFI bindings to much success. This has relied on a
Coercible class within the lib I think I have to rename to something else.
One of the headline features of purescript 0.14 are compiler solved Coercible instances. See purescript/purescript#3351. However, the Coercible on main purescript is different from untagged-union. In particular, Coercible on purescript 0.14 is symmetric - purescript/purescript#3930 , whereas untagged-union Coercible is after something that’s not. Also, we’re looking at JS runtime specific coercions.
For instance, we have an instance for
Coercible Int Number since purescript ints are simply backed by JS numbers. This relationship is not symmetric such that we cannot coerce all Number to Int.
Since Coercible will be central to purescript 0.14, having a separate typeclass with the same name here might be confusing.
Seeking opinions what to rename it to. Also, wondering if there’s something similar on other languages we can take inspiration from. I’m considering
cast instead of
As an aside, I aim to use this heavily on autogenerated aws-sdk bindings and react component bindings I’ve been working on the past weeks.