diff options
Diffstat (limited to 'templates/data.purs.ede')
-rw-r--r-- | templates/data.purs.ede | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/templates/data.purs.ede b/templates/data.purs.ede index ccaa7de..a26f292 100644 --- a/templates/data.purs.ede +++ b/templates/data.purs.ede | |||
@@ -2,8 +2,17 @@ | |||
2 | -- {{ dateTime }} | 2 | -- {{ dateTime }} |
3 | 3 | ||
4 | module {{ moduleName }} where | 4 | module {{ moduleName }} where |
5 | import Prelude | ||
6 | import Data.Generic | ||
7 | import Data.Maybe (Maybe(..)) | ||
8 | import Data.StrMap (StrMap(..)) | ||
9 | import Data.Map (Map(..)) | ||
10 | import Data.List (List(..)) | ||
11 | import Linear | ||
5 | 12 | ||
6 | {% for t in definitions %} | 13 | {% for t in dataAndType %} |
14 | {% case t.value | constType %} | ||
15 | {% when "DataDef" %} | ||
7 | data {{ t.value.dataName }}{% for c in t.value.constructors %} | 16 | data {{ t.value.dataName }}{% for c in t.value.constructors %} |
8 | {% if c.value.fields | hasFieldNames %} | 17 | {% if c.value.fields | hasFieldNames %} |
9 | {% if c.first %}={% else %}|{% endif %} {{ c.value.name }} | 18 | {% if c.first %}={% else %}|{% endif %} {{ c.value.name }} |
@@ -13,4 +22,13 @@ data {{ t.value.dataName }}{% for c in t.value.constructors %} | |||
13 | {% else %} | 22 | {% else %} |
14 | {% if c.first %}={% else %}|{% endif %} {{ c.value.name }}{% for f in c.value.fields %} {{ f.value.fieldType | psType | parens }}{% endfor %}{% endif %}{% endfor %} | 23 | {% if c.first %}={% else %}|{% endif %} {{ c.value.name }}{% for f in c.value.fields %} {{ f.value.fieldType | psType | parens }}{% endfor %}{% endif %}{% endfor %} |
15 | 24 | ||
25 | {% when "TypeAlias" %} | ||
26 | type {{ t.value.aliasName }} = {{ t.value.aliasType | psType }} | ||
27 | |||
28 | {% endcase %} | ||
16 | {% endfor %} | 29 | {% endfor %} |
30 | {% for t in definitions %}{% let l = t.value.instances | length %}{% if l > 0 %}{# FIXME!!! #} | ||
31 | derive instance generic{{ t.value.dataName }} :: Generic {{ t.value.dataName }} | ||
32 | instance show{{ t.value.dataName }} :: Show {{ t.value.dataName }} where show = gShow | ||
33 | instance eq{{ t.value.dataName }} :: Eq {{ t.value.dataName }} where eq = gEq | ||
34 | {% endif %}{% endlet %}{% endfor %} | ||