[ghc-steering-committee] Proposal #569: multiline string literals; Rec: accept

Richard Eisenberg rae at richarde.dev
Fri Dec 29 13:19:05 UTC 2023


I'm pretty agnostic on the whitespace-stripping details here. I think Haskellers will learn to deal with whatever is decided, so I think the choice is pretty low stakes.

On the other hand, I'm a little worried that this doesn't have support for raw strings. That is, even with this, there will still be some users who reach for quasiquotes for multi-line strings, if those strings contain backslashes. Yet I don't want the perfect to become the enemy of the good, so I vote for acceptance.

Richard

> On Dec 27, 2023, at 2:23 PM, Eric Seidel <eric at seidel.io> wrote:
> 
> Dear Committee,
> 
> Brandon Chinn has proposed[1] adding multi-line strings to Haskell. Most languages these days support multi-line strings, even Java has them as of Java 17 (which coincidentally is a strong inspiration for Brandon's proposal). Yet in Haskell we have to resort to tricks like `unlines`  or quasiquoters.
> 
> Brandon's proposal adds support for triple-quote delimited multi-line strings, e.g.
> 
> ```
> adtParseJSON =
>  """
>  \\v -> case v of
>    Aeson.Null -> pure PrintStyleInherit
>    Aeson.String "" -> pure PrintStyleInherit
>    _ -> PrintStyleOverride <$> Aeson.parseJSON v
>  """
> ```
> 
> The rules are largely inspired by Java's text blocks[2] proposal, which I've also read and find very pragmatic. Honestly, I encourage the Committee to read the Java proposal as well. Haskell innovates in many areas of language design, but the lexical structure of strings feels like an area where we should conserve our innovation tokens. Brandon's proposal does a great job here of starting from an established baseline and adapting it to Haskell's idiosyncrasies. 
> 
> One point I would draw the Committee's attention to is the handling of characters on the opening line[3]. My only concern with this proposal is that omitting the opening line from the prefix calculation can lead to some counterintuitive behavior. For example
> 
> ```
> s = """ foo
>        bar
>    """
> ```
> 
> would be parsed as `" foo\nbar"`. I'm on the fence about whether we should try to be more prescriptive here, or just expect that Haskeller's will learn to avoid this corner case. I think it's probably fine.
> 
> On balance I think we should accept the proposal.
> 
> Thanks!
> Eric
> 
> [1]: https://github.com/ghc-proposals/ghc-proposals/pull/569
> [2]: https://openjdk.org/jeps/378
> [3]: https://github.com/brandonchinn178/ghc-proposals/blob/multiline-strings/proposals/0569-multiline-strings.rst#33ignore-leading-characters
> _______________________________________________
> ghc-steering-committee mailing list
> ghc-steering-committee at haskell.org
> https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee



More information about the ghc-steering-committee mailing list