Skip to content

joprice/type-formatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

type-formatter

Scala compiler plugin to format type errors

This is a proof of concept and has not been tested against a large project. Use at your own risk.

Note: This feature was added directly to the compiler by @VladUreche and is now available in the 2.12.2 https://github.com/scala/scala/pull/5589/files

This plugin hijacks the compiler's error reporting to improve the readability of symbolic infix types:

Before:

[error]  found   : shapeless.::[Int,shapeless.::[String,shapeless.::[Double,shapeless.HNil]]]
[error]  required: Int
[error]   val i: Int = 1 :: "a" :: 1.1 :: HNil

After:

[error]  found   : Int :: String :: Double :: shapeless.HNil
[error]  required: Int
[error]   val i: Int = 1 :: "a" :: 1.1 :: HNil

All the credit goes to Miles Sabin and Li Haoyi, since this is just gluing together code from pprint and si2712fix.

TODO

  • add annotation/option to allow non-symbolic types like Xor to be printed infix

About

Scala compiler plugin to format type errors

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages