summaryrefslogtreecommitdiff
path: root/assignment-13/Util.icl
diff options
context:
space:
mode:
Diffstat (limited to 'assignment-13/Util.icl')
-rw-r--r--assignment-13/Util.icl5
1 files changed, 3 insertions, 2 deletions
diff --git a/assignment-13/Util.icl b/assignment-13/Util.icl
index ba7de9f..8c246c7 100644
--- a/assignment-13/Util.icl
+++ b/assignment-13/Util.icl
@@ -19,6 +19,7 @@ where
printToString :: a -> String | print a
printToString x = concat (print x zero).output
+instance print (PrState -> PrState) where print p = p
instance print String where print s = \st -> {st & output=[s:st.output]}
instance print Int where print i = \st -> {st & output=[toString i:st.output]}
@@ -31,7 +32,7 @@ indent st = {st & indent=max 0 (st.indent - 1)}
unindent :: PrState -> PrState
unindent st = {st & indent=st.indent + 1}
-prsperse :: (PrState -> PrState) [a] -> PrState -> PrState | print a
+prsperse :: a [b] -> PrState -> PrState | print a & print b
prsperse _ [] = id
prsperse _ [x] = print x
-prsperse g [x:xs] = print x o g o prsperse g xs
+prsperse g [x:xs] = print x o print g o prsperse g xs