Closed neongreen closed 4 years ago
@neongreen I think the problem with pretty-simple is two-fold:
pretty-simple doesn't handle non-balanced brackets: #27. Here's the expression that "[']']"
is parsed into:
[ Brackets
( CommaSeparated
{ unCommaSeparated =
[ [ Other "'" ] ]
}
)
, Other "'"
]
Basically this means there are brackets surrounding a '
, and then a single '
. The final bracket is removed. The reason there are spaces around the first quote is that pretty-simple prints spaces inside of brackets by default.
This should instead be parsed into something like this:
[ Brackets
( CommaSeparated
{ unCommaSeparated =
[ [ CharLit ']' ] ]
}
)
]
pretty-simple doesn't have a special parser for Haskell characters (e.g. things like 'a'
or 'X'
or ']'
). So it doesn't realize that ']'
is supposed to be a character (and not a closing bracket).
It would be nice to add an expression for characters (like the CharLit
I've used above).
If you want to send a PR fixing either of these things, it would definitely be accepted!
If you wanted to fix this, you'd mainly have to edit the expression parser, which lives in these two files:
Text.Pretty.Simple> pStringNoColor "[']']" "[ ' ]'"
The correct output should be
"[']'"
.
Should that be "[ ']' ]"
in analogy to
> pStringNoColor "[1]"
"[ 1 ]"
?
The correct output should be
"[']'"
.