I have R1 and R2 record types and I need to pass either R1 or R2 to a foreign function (it can handle either r1 or r2 record structure) is it possible to do this (I thought maybe via conversion to Foreign Object)?
Or do I need to declare two different foreign imports (with different type signatures for passing R1 and R2) pointing to the same js function?
Another way I found using unsafeCoerce for type conversion:
foreign import data R1orR2 ∷ Type
fromR1 :: R1 -> R1orR2
fromR1 = unsafeCoerce
fromR2 :: R2 -> R1orR2
fromR2 = unsafeCoerce
So maybe there some other ways.