scalaz-plugin
scalaz-plugin copied to clipboard
A compiler plugin that will improve on the scala compiler on the assumption that the user is using the Scalazzi-safe subset of Scala.
Scalazzi compiler plugin
A compiler plugin that improves on the scala compiler on the assumption that the user is using the Scalazzi-safe subset of Scala.
What does this plugin do?
- [x] Sufficiency checker. Example.
- [x] Non-ambigious typeclass resolution. Example.
- [x] Orphan instance checker. Some examples.
- [x] Polymorphic function optimization.
See test/files for more examples. We would like to get a lot more things done eventually, see open issues.
What is Scalazzi
- No
null
. - No catching exceptions in pure code.
- No type casing (
isInstanceOf
). - No type casting (
asInstanceOf
). - No side-effects.
- No
equals
,toString
,hashCode
. - No
notify
orwait
in pure code. - No
.getClass
.
We are more interested in Scalazzi+, which adds:
- Only total functions.
-
Eq
(used in laws and pattern matching) must satisfy:- Identity of indiscernibles (indiscernible values are equal).
- Indiscernibility of identicals (equal values are indiscernible from each other).
The last requirement might seem a bit cryptic, but it has a wide range of implications, for example:
if (a === b) {
// now we know that a.type === b.type
}