-
Notifications
You must be signed in to change notification settings - Fork 0
/
HTML.hs
98 lines (91 loc) · 2.68 KB
/
HTML.hs
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
module HTML where
import Text.Blaze.Html5 hiding (map)
import qualified Text.Blaze.Html5 as H
import Text.Blaze.Html5.Attributes
import Data.List
import DataTypes
import Data.Monoid
proof2html :: BinTree DecoratedSequent -> Html
proof2html (Leaf lab s) =
table $ do
tr $ toHtml ""
tr $ do
td $ hr
td $ lab2html lab
tr $ td $ decoratedSeq2html s
proof2html (Unary lab s t) =
table $ do
tr $ td $ proof2html t
tr $ do
td $ hr
td $ lab2html lab
tr $ td $ decoratedSeq2html s
proof2html (Branch lab l s r) =
table $ do
tr $ do
td $ proof2html l
td $ proof2html r
tr $ do
(td $ hr) ! (colspan $ toValue "2")
td $ lab2html lab
tr $ (td $ decoratedSeq2html s) ! (colspan $ toValue "2")
lab2html :: Label -> Html
lab2html Id = toHtml "id"
lab2html ImpL = preEscapedToHtml "→L"
lab2html ImpR = preEscapedToHtml "→R"
lab2html MonL = preEscapedToHtml "◊L"
lab2html MonR = preEscapedToHtml "◊R"
lambda2html :: LambdaTerm -> Html
lambda2html (C c) = em $ toHtml c
lambda2html (V n) | n < length sanevars && n >= 0 =
toHtml $ sanevars !! n
| otherwise = toHtml $ "v" ++ show n
lambda2html (Lambda x b) = do
preEscapedToHtml "λ"
lambda2html x
toHtml "."
lambda2html b
lambda2html (Eta f) = do
preEscapedToHtml "η("
lambda2html f
toHtml ")"
lambda2html (App f@(Lambda _ _) a) = do
toHtml "("
lambda2html f
toHtml ")("
lambda2html a
toHtml ")"
lambda2html (App f@(_ :*: _) a) = do
toHtml "("
lambda2html f
toHtml ")("
lambda2html a
toHtml ")"
lambda2html (App f a) = do
lambda2html f
toHtml "("
lambda2html a
toHtml ")"
lambda2html (m :*: k) = do
lambda2html m
preEscapedToHtml " ∗ "
lambda2html k
decoratedSeq2html :: DecoratedSequent -> Html
decoratedSeq2html (gamma,c) = mconcat left >> toHtml " => " >> f c where
left = intersperse (toHtml ", ") $ map f gamma
f (DF _ lt f) = lambda2html lt >> toHtml " : " >> formula2html f
-- |Texifies a formula (now with smart parentheses!)
formula2html :: Formula -> Html
formula2html (Atom a _) = toHtml a
formula2html (Var x _) = toHtml x
formula2html (M (Atom a _) _) = preEscapedToHtml "◊" >> toHtml a
formula2html (M (Var x _) _) = preEscapedToHtml "◊" >> toHtml x
formula2html (M f _) = preEscapedToHtml "◊(" >> formula2html f >> toHtml ")"
formula2html (I (Atom a _) f _) = toHtml a >> preEscapedToHtml " → " >> formula2html f
formula2html (I (Var a _) f _) = toHtml a >> preEscapedToHtml " → " >> formula2html f
formula2html (I d@(M _ _) f _) = formula2html d >> preEscapedToHtml " → " >> formula2html f
formula2html (I f g _) = do
toHtml "("
formula2html f
preEscapedToHtml ") → "
formula2html g