iface: add instance `IfThenElseable Viewer`
authorJulien Moutinho <julm@sourcephile.fr>
Fri, 15 Sep 2023 19:46:43 +0000 (21:46 +0200)
committerJulien Moutinho <julm@sourcephile.fr>
Fri, 15 Sep 2023 19:46:43 +0000 (21:46 +0200)
src/Symantic/Semantics/Viewer.hs

index a29af2cd12c0e703e903a5cf13e6504f9e2e1519..e4eb93236575e646605286ff017353d02bb5fb0e 100644 (file)
@@ -144,5 +144,13 @@ instance Maybeable Viewer where
   nothing = "Nothing"
   just = "Just"
 instance IfThenElseable Viewer where
-  ifThenElse test ok ko =
-    "if" .@ test .@ "then" .@ ok .@ "else" .@ ko
+  ifThenElse test ok ko = Viewer Fun.$ \env ->
+    pairViewer env op Fun.$
+    showString "if"
+      Fun.. runViewer test env{viewEnv_op = (op, SideL)}
+      Fun.. showString "then"
+      Fun.. runViewer ok env{viewEnv_op = (op, SideL)}
+      Fun.. showString "else"
+      Fun.. runViewer ko env{viewEnv_op = (op, SideL)}
+    where
+    op = infixN 0