joprice/type-formatter
Scala compiler plugin to format type errors
{ "createdAt": "2016-05-20T14:11:50Z", "defaultBranch": "master", "description": "Scala compiler plugin to format type errors", "fullName": "joprice/type-formatter", "homepage": null, "language": "Scala", "name": "type-formatter", "pushedAt": "2017-04-22T16:33:48Z", "stargazersCount": 9, "topics": [], "updatedAt": "2022-03-12T08:23:36Z", "url": "https://github.com/joprice/type-formatter"}type-formatter
Section titled “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 :: HNilAfter:
[error] found : Int :: String :: Double :: shapeless.HNil[error] required: Int[error] val i: Int = 1 :: "a" :: 1.1 :: HNilAll the credit goes to Miles Sabin and Li Haoyi, since this is just gluing together code from [pprint]!( https://github.com/lihaoyi/upickle-pprint/blob/c3227d34547fe974a47f74f537be4cf6eaefbc22/pprint/shared/src/main/scala-2.11/pprint/TPrintImpl.scala) and si2712fix.
- add annotation/option to allow non-symbolic types like Xor to be printed infix