-
Notifications
You must be signed in to change notification settings - Fork 0
/
to-json.dhall
67 lines (51 loc) · 1.82 KB
/
to-json.dhall
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
let types = ./types.dhall
let snippets = ./snippets.dhall
let map =
https://prelude.dhall-lang.org/v20.2.0/List/map.dhall
sha256:dd845ffb4568d40327f2a817eb42d1c6138b929ca758d50bc33112ef3c885680
let WithKD = types.WithKey ⩓ types.WithDescription
let render-ultisnip
: types.UltiSnip → Text
= λ(s : types.UltiSnip) →
''
snippet ${s.key} "${s.description}" ${s.mode}
${s.body}
endsnippet
''
let render-yas
: types.YasSnippet → Text
= λ(s : types.YasSnippet) →
''
# -*- mode: snippet -*-
# name: ${s.description}
# key: ${s.key}
# --
${s.body}
''
let render-snippet
: types.Snippet → types.RenderedSnippet
= λ(s : types.Snippet) →
{ yas = render-yas s.yas, ultisnip = render-ultisnip s.ultisnip }
let apply-key-and-description
: WithKD → types.PreSnippet → types.Snippet
= λ(kd : WithKD) →
λ(s : types.PreSnippet) →
{ yas = s.yas ∧ kd, ultisnip = s.ultisnip ∧ kd } : types.Snippet
let RenderedImpl =
{ language : types.Language, snippet : types.RenderedSnippet }
let render-impl
: WithKD → types.LanguageImpl → RenderedImpl
= λ(kd : WithKD) →
λ(i : types.LanguageImpl) →
let snippet = apply-key-and-description kd i.snippet
in { language = i.language, snippet = render-snippet snippet }
let RenderedBundle = { bundle : List RenderedImpl } ⩓ WithKD
let render-bundle
: types.Bundle → RenderedBundle
= λ(b : types.Bundle) →
let kd = { key = b.key, description = b.description }
in b
with bundle =
map types.LanguageImpl RenderedImpl (render-impl kd) b.bundle
let render-snippets = map types.Bundle RenderedBundle render-bundle
in render-snippets snippets