summaryrefslogtreecommitdiff
path: root/templates/encode.hs.ede
diff options
context:
space:
mode:
Diffstat (limited to 'templates/encode.hs.ede')
-rw-r--r--templates/encode.hs.ede26
1 files changed, 26 insertions, 0 deletions
diff --git a/templates/encode.hs.ede b/templates/encode.hs.ede
new file mode 100644
index 0000000..f305eb1
--- /dev/null
+++ b/templates/encode.hs.ede
@@ -0,0 +1,26 @@
1-- generated file, do not modify!
2-- {{ dateTime }}
3
4{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
5module {{ moduleName }}Encode where
6
7import Data.Text
8import Data.Aeson hiding (Value,Bool)
9import Data.Aeson.Types hiding (Value,Bool)
10import Linear
11
12import {{ moduleName }}
13
14(.-) :: Text -> Text -> Pair
15a .- b = a .= b
16
17{% for t in definitions %}
18instance ToJSON {{ t.value.dataName }} where
19 toJSON v = case v of{% for c in t.value.constructors %}{% if c.value.fields | hasFieldNames %}
20 {{ c.value.name }}{..} -> object
21 [ "tag" .- "{{ c.value.name }}"{% for f in c.value.fields %}
22 , "{{ f.value.fieldName }}" .= {{ f.value.fieldName }}{% endfor %}
23 ]{% else %}
24 {{ c.value.name }}{% for f in c.value.fields %} arg{{ f.index0 }}{% endfor %} -> object [ "tag" .- "{{ c.value.name }}"{% for f in c.value.fields %}, "arg{{ f.index0 }}" .= arg{{ f.index0 }}{% endfor %}]{% endif %}{% endfor %}
25
26{% endfor %} \ No newline at end of file