Interpolate plugin for GHC
main :: IO ()
main =
let a = 5
b = 6
in putStrLn "#a + #b = #{ a + b }"
>>> 5 + 6 = 11
Plugin can interpolate values and Haskell expressions into strings (forall str. IsString str
) with your custom toString
function.
iii
Pros and Why not - Interpolating with plugin looks like valid Haskell code
- Your custom
toString
- Simple implementation
iii
Cons and Why - Since it's a plugin, it must be defined outside of your project
- To specify
toString
function you need to create your own plugin based on this one - String literals not supported inside of placeholders
-- will be parsed by GHC as 3 strings separated by `foo` and `bar`
"#{ if cond then "foo" else "bar" }"
- HLS shows plugin's errors at the top of file