OSDN Git Service

A start on Joy types.
authorsforman <sforman@hushmail.com>
Fri, 28 Jul 2023 22:04:35 +0000 (15:04 -0700)
committersforman <sforman@hushmail.com>
Fri, 28 Jul 2023 22:04:35 +0000 (15:04 -0700)
implementations/Elm/src/Joy.elm [new file with mode: 0644]

diff --git a/implementations/Elm/src/Joy.elm b/implementations/Elm/src/Joy.elm
new file mode 100644 (file)
index 0000000..5d5c641
--- /dev/null
@@ -0,0 +1,25 @@
+module Joy exposing (joyTermToString)
+
+
+type JoyType
+    = Symbol String
+    | Integer Int
+    | JoyList (List JoyType)
+    | JoyTrue
+    | JoyFalse
+
+
+joyTermToString : JoyType -> String
+joyTermToString term =
+    case term of
+        Symbol name ->
+            name
+        Integer n ->
+            String.fromInt n
+        JoyTrue ->
+            "true"
+        JoyFalse ->
+            "false"
+        JoyList list ->
+            "[" ++ (String.join " " (List.map joyTermToString list)) ++ "]"
+