2021-02-18 16:07:22 +03:00
|
|
|
module StringLiteral
|
2021-01-29 12:11:22 +03:00
|
|
|
|
2021-02-20 22:11:01 +03:00
|
|
|
rawStr : String
|
|
|
|
rawStr = #""""""#
|
2021-01-29 12:11:22 +03:00
|
|
|
|
2021-02-20 22:11:01 +03:00
|
|
|
interp1 : String
|
|
|
|
interp1 = "Just 1 + Just 2 = \{
|
2021-02-18 16:07:22 +03:00
|
|
|
show $ do a <- Just 1
|
|
|
|
b <- Just 2
|
|
|
|
Just (a + b)
|
|
|
|
}"
|
|
|
|
|
2021-02-20 22:11:01 +03:00
|
|
|
interp2 : String
|
|
|
|
interp2 = "hello\{ " " ++ ##"world\##{#"."#}"## }"
|
|
|
|
|
2021-02-20 12:59:06 +03:00
|
|
|
multi1 : String
|
|
|
|
multi1 = """
|
|
|
|
[project]
|
|
|
|
name: "project"
|
|
|
|
version: "0.1.0"
|
|
|
|
[deps]
|
|
|
|
"semver" = 0.2
|
|
|
|
"""
|
|
|
|
|
|
|
|
multi2 : String
|
2021-02-20 22:11:01 +03:00
|
|
|
multi2 = #"""
|
2021-02-23 08:10:36 +03:00
|
|
|
a\#
|
2021-02-20 12:59:06 +03:00
|
|
|
b\n
|
2021-02-20 22:11:01 +03:00
|
|
|
\#{"c"}
|
|
|
|
"""#
|
2021-02-20 12:59:06 +03:00
|
|
|
|
|
|
|
multi3 : String
|
|
|
|
multi3 = """
|
|
|
|
\{"sticking"} \{"together"}\{
|
2021-02-20 22:11:01 +03:00
|
|
|
""}\{#"""
|
2021-02-20 12:59:06 +03:00
|
|
|
!
|
|
|
|
|
2021-02-20 22:11:01 +03:00
|
|
|
"""#}
|
2021-02-20 12:59:06 +03:00
|
|
|
"""
|
|
|
|
|
|
|
|
multi4 : String
|
|
|
|
multi4 = """
|
2021-02-20 22:11:01 +03:00
|
|
|
A very very \n\nvery very very \n
|
|
|
|
very long string. \
|
2021-02-20 12:59:06 +03:00
|
|
|
"""
|
|
|
|
|
2021-01-29 12:11:22 +03:00
|
|
|
test : IO ()
|
2021-02-20 22:11:01 +03:00
|
|
|
test = do
|
|
|
|
putStrLn rawStr
|
|
|
|
putStrLn interp1
|
2021-02-18 16:07:22 +03:00
|
|
|
putStrLn interp2
|
|
|
|
let idris = "Idris"
|
|
|
|
putStrLn "Hello \{idris ++ show 2}!"
|
2021-02-20 12:59:06 +03:00
|
|
|
putStrLn multi1
|
|
|
|
putStrLn multi2
|
|
|
|
putStrLn multi3
|
|
|
|
putStrLn multi4
|
|
|
|
putStrLn """
|
2021-02-20 22:11:01 +03:00
|
|
|
"""
|
2021-02-20 22:13:13 +03:00
|
|
|
putStrLn ##"""
|
2021-02-20 22:11:01 +03:00
|
|
|
a
|
|
|
|
"""##
|
2021-02-20 22:13:13 +03:00
|
|
|
putStrLn ##"""
|
2021-02-20 22:11:01 +03:00
|
|
|
name: #"foo"
|
|
|
|
version: "bar"
|
|
|
|
bzs: \#\'a\n\t\\'
|
|
|
|
"""
|
|
|
|
"""##
|
2021-07-13 13:52:15 +03:00
|
|
|
printLn "contains\NULcharacter"
|