PureScript: Warn type class
I recently added user defined warnings to the PureScript
compiler. This feature will be available in the release following 0.10.5
.
You can find the feature request here.
Definition
To print a warning during compilation, we added a type class called Warn
. It
is located in the Prim
module and is defined as:
It is indexed by a Symbol
- you can read about symbols here.
Use
If this type class is used as a constraint in a type, for example:
When this function is used and the compiler starts solving for the constraints,
it will trivially solve the Warn
instance and print out the message.
Example
Another use case is a deprecation message with upgrade instructions:
I’ve written about this on the documentation repo.