-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.idr
48 lines (39 loc) · 944 Bytes
/
Main.idr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module Main
import Lightyear.Core
import Lightyear.Combinators
import Lightyear.Strings as LS
import Text.Mustache.Parser
test1 : String
test1 = """
Hello {{name}}
You have just won {{value}} dollars!
{{#in_ca}}
Well!, {{taxed_value}} dollars, after taxes.
{{/in_ca}}
"""
comprehensive : String
comprehensive = """
This is a comprehensive example of Mustache template.
It has {{first-thing}} and {{&second-thing}}, as well as a bit of
{{third-thing}}.
John has the following items today:
{{#items}}
* {{.}}
{{/items}}
{{^items}}
None.
{{/items}}
We could also use this text as a start of our conversation:
{{>lorem-ipsum}}
But we won't.
"""
main : IO ()
main = do
fname <- getLine
Right txt <- readFile fname
| putStrLn "Can't read file"
putStrLn txt
case LS.parse (pMustache eof) txt of
Right res => putStrLn ("Successfully parsed " <+> show (length res) <+> " nodes!")
Left err => putStrLn err
pure ()