mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-17 16:21:46 +03:00
1576a578a0
* contrib library unused import removal * remove a few unused imports. * another round of unused import removal * another round of unused import deletion. * another round of unused import deletion.
32 lines
1.0 KiB
Idris
32 lines
1.0 KiB
Idris
||| A DYI version of 'string interpolation', mimicking Python 3's 'f-string' syntax
|
|
||| Not as fancy
|
|
module Data.String.Interpolation
|
|
|
|
namespace Data.String.Interpolation.Basic
|
|
%inline
|
|
public export
|
|
F : List String -> String
|
|
F strs = concat (strs)
|
|
|
|
namespace Data.String.Interpolation.Nested
|
|
%inline
|
|
public export
|
|
F : List (List String) -> String
|
|
F strss = F (concat strss)
|
|
|
|
{- Examples:
|
|
fstring : String
|
|
fstring = let apples = "apples" in
|
|
F["I have some ", apples," here."] --- cf. f"I have some {apples} here."
|
|
|
|
multiline : String
|
|
multiline = let name = "Edwin"
|
|
profession = "Hacker"
|
|
affiliation = "the University of St. Andrews" in --- cf.
|
|
F [["Hi ",name,". " ] --- f"Hi {name}. " \
|
|
,["You are a ",profession,". "] --- f"You are a {profession}. " \
|
|
,["You were in ",affiliation,"."] --- f"You were in {affiliation}."
|
|
]
|
|
|
|
-}
|