Stream: beginners

Topic: Heredoc?


view this post on Zulip Ryan Bates (Nov 18 2023 at 05:40):

Does Roc support heredoc (multiline string)? It's really handy in other languages when you need to paste in a big string without worrying about escaping " character.

view this post on Zulip Brian Carroll (Nov 18 2023 at 06:47):

It has multi line strings

""""This string
     has multiple
     lines
""""

Not exactly the same as heredoc because there's no special string at the start and end

view this post on Zulip Ryan Bates (Nov 18 2023 at 07:10):

Good to know, thanks! Do you know if this is documented anywhere? I couldn't find it in the tutorial or Str module docs.

view this post on Zulip Ryan Bates (Nov 18 2023 at 07:16):

Looks like 3 quotes work, not 4: """

view this post on Zulip Hannes (Nov 18 2023 at 07:29):

Roc also supports importing a file at compile time as a string

view this post on Zulip Luke Boswell (Nov 18 2023 at 07:36):

IngestFiles/main.roc here is an example that shows how to do that. Basically

imports [
    "some-file" as someStr : Str,
    "some-file" as someBytes : List U8,
]

view this post on Zulip Brian Carroll (Nov 18 2023 at 07:45):

Ryan Bates said:

Looks like 3 quotes work, not 4: """

Oh I meant to type 3! I was on mobile

view this post on Zulip Ryan Bates (Nov 19 2023 at 05:06):

@Luke Boswell wow I didn't know you could import a text file like this, it will save me a lot of code, thanks!


Last updated: Jul 06 2025 at 12:14 UTC