-- generated file, do not modify! -- {{ dateTime }} {-# LANGUAGE OverloadedStrings, RecordWildCards #-} module {{ moduleName }}Encode where import Data.Text import Data.Aeson hiding (Value,Bool) import Data.Aeson.Types hiding (Value,Bool) import Linear import {{ moduleName }} (.-) :: Text -> Text -> Pair a .- b = a .= b {% for t in definitions %} instance ToJSON {{ t.value.dataName }} where toJSON v = case v of{% for c in t.value.constructors %}{% if c.value.fields | hasFieldNames %} {{ c.value.name }}{..} -> object [ "tag" .- "{{ c.value.name }}"{% for f in c.value.fields %} , "{{ f.value.fieldName }}" .= {{ f.value.fieldName }}{% endfor %} ]{% else %} {{ 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 %} {% endfor %}