-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtmp
More file actions
179 lines (124 loc) · 4.15 KB
/
tmp
File metadata and controls
179 lines (124 loc) · 4.15 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
Data ===> Render
^----------|
* - Syntax separation. i.e. JSON + Mustache Template
* - No high order logic support between data and rendering languages. i.e:
the text to be rendered depends on the output format or page size.
* + swap out rendering format
* + logic support for data layer
Data <===> Render
* + marry the data and render syntaxes
* i.e auto link generation
* + non-turring complete
* + types lots of 'em and inference.
* extensible "markup language" syntax
* keep all provanence information for output files / derivations (for any
build system)
- the most general information is the file system heirarchy of the final
produced derivation
Nix
1. Write Text <--|-- Content
1. Create data <-|
1. Create outputs (derivations)
|-------------------------|
v--------------| |
datastructure ~ text ~ (derivation - fs. Hierarchy)
Final Encoding
Module = { text : Text; drvs = ???; a = { text = ???; drvs = ???; } }
text :: Lens Module Text
list :: [Module] -> Module
Text is the language provided by the rendering system.
Conix
Initial
DhallAeson a -> Text
Final
type Doc = (Text, Text)
render :: (Text -> a) -> Content2 a -> Content2 a
render r (Markup t) = Rendered (r t)
render _ x = x
data ListType = Enum | Bullet | Ordered
data ListItem =
final encode
mdList :: [Text] -> Text
mdList [ (f a) (g b) ... ]
mdList' :: [[Text]] -> [Text]
mdList = pure . mdList . fmap mconcat
1. a derivation at the top of the tree
(not needed because not fixing this gives the user more power)
1.
````````
conix: dir "bar" [(mdFile "foo") (htmlFile "baz")] ()
`````
type Pandoc a
= TextLit Text
| BulletList [a]
| EnumList [a]
| Table (Map Text [a])
| Heading Natural a
| HRule
| Paragraph [a]
deriving Functor
type MarkupCodeF a = FreeF a PandocF
type MarkupCode a = Fix (MarkupCodeF a)
label :: Name -> MarkupCode -> MarkupCode
label = Labeled
labelHidden :: Name -> MarkupCode a -> MarkupCode a
labelHidden name = Labeled name . pure
a b
Dir -> (Name, Dir -> (Name, File -> Paragraph [a]
"conix.a.b.c"
data FileHierarchyF a b
= File RenderType (MarkupCode a)
| LocalPath FilePath
| Dir (Map Name b)
deriving Functor
type FileHierarchy a = Fix (FileHierarchyF a)
type RenderType
= Html HtmlPandocArgs
| PDF PDFPandocArgs
| Markdown
type PureData = NixValue
type LabelledDataF a = FreeF a (Map Name)
type LabelledData = Fix (LabelledDataF a)
type LabeledDataPath = [Name]
-- Good API design: avoid parsing / patching things.
-- md
-- linkTo "a.b.c.d" ======> "a/b/c.md"
-- ======> "a/b/c#d"
-- html
renderCode :: MarkupCode -> FileHierarchy
renderCode = File
Markdown/RST/LaTeX Formatted Text
|
V
code :: MarkupCode -> FileHierarchy
code = drv . renderCode
modifyCode :: (MarkupCode -> MarkupCode) -> FileHierarchy -> FileHierarchy
modifyCode = over mds
mds :: Traversal FileHierarchy MarkupCode
toText :: PureData -> MarkupCode
instance Monoid FileHierarchy
instance Monoid Page
-- LabeledDataPath -> Lens FileHierarchy a
get :: LabeledDataPath -> FileHierarchy -> a
set :: LabeledDataPath -> a -> FileHierarchy -> FileHierarchy
(Monoid s) => StateF s a (In Nix)
= Get (s -> a) ==========> s -> a (in Nix)
| Set s a ==========> { x = a }
evalMarkdown :: Alg MarkupCodeF a r -> MarkupCode a -> r
evalFileHierarchy :: Alg FileHierarchyF a d -> FileHierarchy a -> d
linkTo :: LabeledDataPath -> FileHierarchy -> MarkupCode
linkTo = ???
dir :: DirPath -> [ FileHierarchy ] -> FileHierarchy
file :: Name -> Text -> FileHierarchy
-- r ~ (Derivation, LabelledData)
run :: Alg (FileHierarchyF a) (r -> r) -> (r -> FileHierarchy a) -> r
run alg f = fix (cata alg . f)
|-------------------------------------|--> Derivation | NixValue
| |
Evaluated to Create |
| |
--------------------- v
File System Tree |------------|
--------------------- | Data Tree |
Content Tree <--Consumed To Create---|------------|
---------------------