Implement Term as an AST builder + interpreter, so that tests and ormolu-live (and Fourmolu) don't have to use hacky work-arounds to print exceptions.
The monad instance is a bit sus, but no one should really be using <- in any Term blocks. If someone does, it'll just blow up in tests. We can get rid of the monad weirdness by just writing everything as
prettyOrmoluException :: OrmoluException -> PrettyText
prettyOrmoluException = \case
OrmoluParsingFailed s e ->
[ WithBold [putOutputable s]
, ...
]
type PrettyText = [PrettyNode]
data PrettyNode
= OutputText Text
| WithColor Color PrettyText
| WithBold PrettyText
hPutPretty :: ColorMode -> Handle -> PrettyText -> IO ()
getPretty :: PrettyText -> Text
But the do-notation does look a bit nicer, so I didn't want to rewrite all of that for now.
Implement Term as an AST builder + interpreter, so that tests and ormolu-live (and Fourmolu) don't have to use hacky work-arounds to print exceptions.
The monad instance is a bit sus, but no one should really be using
<-
in anyTerm
blocks. If someone does, it'll just blow up in tests. We can get rid of the monad weirdness by just writing everything asBut the do-notation does look a bit nicer, so I didn't want to rewrite all of that for now.