0 | ||| A DYI version of 'string interpolation', mimicking Python 3's 'f-string' syntax
 1 | ||| Not as fancy
 2 | module Data.String.Interpolation
 3 |
 4 | namespace Data.String.Interpolation.Basic
 5 |   %inline
 6 |   public export
 7 |   F : List String -> String
 8 |   F strs = concat (strs)
 9 |
10 | namespace Data.String.Interpolation.Nested
11 |   %inline
12 |   public export
13 |   F : List (List String) -> String
14 |   F strss = F (concat strss)
15 |
16 | {- Examples:
17 | fstring : String
18 | fstring = let apples = "apples" in
19 |           F["I have some ", apples," here."]                     --- cf. f"I have some {apples} here."
20 |
21 | multiline : String
22 | multiline = let name = "Edwin"
23 |                 profession = "Hacker"
24 |                 affiliation = "the University of St. Andrews" in --- cf.
25 |                 F [["Hi ",name,". "             ]                --- f"Hi {name}. "              \
26 |                   ,["You are a ",profession,". "]                --- f"You are a {profession}. " \
27 |                   ,["You were in ",affiliation,"."]              --- f"You were in {affiliation}."
28 |                   ]
29 |
30 | -}
31 |