summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assignment-12/gastje.dcl2
-rw-r--r--assignment-12/gastje.icl5
2 files changed, 4 insertions, 3 deletions
diff --git a/assignment-12/gastje.dcl b/assignment-12/gastje.dcl
index a52618c..9fbf8fe 100644
--- a/assignment-12/gastje.dcl
+++ b/assignment-12/gastje.dcl
@@ -19,7 +19,7 @@ class testArg a | gen{|*|}, string{|*|}, gEq{|*|} a
generic gen a :: [a]
derive gen Int, Bool, Char, UNIT, PAIR, EITHER, CONS, OBJECT, RECORD, FIELD
generic string a :: a -> String
-derive string Int, Bool, Char, UNIT, PAIR, EITHER, CONS of gcd, OBJECT, RECORD of grd, FIELD of gfd
+derive string Int, Bool, Char, Real, UNIT, PAIR, EITHER, CONS of gcd, OBJECT, RECORD of grd, FIELD of gfd
:: Property
= E.p t: (For) infix 0 (t -> p) [t] & prop p & string{|*|} t
diff --git a/assignment-12/gastje.icl b/assignment-12/gastje.icl
index 06148cf..d3b20ce 100644
--- a/assignment-12/gastje.icl
+++ b/assignment-12/gastje.icl
@@ -54,6 +54,7 @@ generic string a :: a -> String
string{|Int|} i = toString i
string{|Bool|} b = toString b
string{|Char|} c = toString ['\'',c,'\'']
+string{|Real|} r = toString r
string{|UNIT|} _ = ""
string{|PAIR|} f g (PAIR x y) = f x + " " + g y
string{|EITHER|} f g (LEFT x) = f x
@@ -88,8 +89,8 @@ where
rev [x:r] accu = rev r [x:accu]
/**
- * TODO: mixing deep and shallow embedding. This is not how this is supposed to
- * be done. These can be plain functions or classes.
+ * Making this one ADT makes type specifications more natural. You can e.g.
+ * have 'Int Int -> Property' rather than 'Int Int -> Equals (Int)' or so.
*/
:: Property
= E.p t: (For) infix 0 (t -> p) [t] & prop p & string{|*|} t