instance print VarDecl where
print (VarDecl _ t i e) = maybe ["var"] print t ++ [" ":i:"=":print e] ++ [";"]
+instance toString VarDecl where
+ toString v = concat (print v)
instance toString Type where
toString t = concat $ print t
print FieldTl = print "tl"
print FieldSnd = print "snd"
print FieldFst = print "fst"
+instance toString FieldSelector where
+ toString fs = concat $ print fs
instance print VarDef where
print (VarDef i fs) = printersperse "." [i:printersperse "" fs]
print (FunExpr _ id as fs) = printFunCall id as ++ printSelectors fs
print (EmptyListExpr _) = ["[]"]
print (TupleExpr _ (e1, e2)) = ["(":print e1] ++ [",":print e2] ++ [")"]
+instance toString Expr where
+ toString e = concat $ print e
printSelectors :: [FieldSelector] -> [String]
printSelectors x = case x of [] = [""]; _ = [".":printersperse "." x]