1 min readMay 28, 2019
Hey! There are tradeoffs to both options. One advantage to using a phantom type instead of two separate distinct types is it allows you to create functions that accept a single type without caring about type parameter.
For example, you could create a reset
function that resets all of the fields of a form to their original default values regardless of whether the form being reset is valid or invalid.
With two opaque types this would require two reset
functions, one for a valid form data and one for an invalid form data.