From 7eb6d767daa24d08d609bad83d82985ffb32c762 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 19 Sep 2017 22:33:54 -0400 Subject: - Changed the terminology of monoids ("append" -> "compose", "unit" -> "identity"). --- stdlib/source/lux/data/format/json.lux | 40 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'stdlib/source/lux/data/format/json.lux') diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux index 95d689059..1cbf9e665 100644 --- a/stdlib/source/lux/data/format/json.lux +++ b/stdlib/source/lux/data/format/json.lux @@ -102,7 +102,7 @@ (#R;Success (d;keys obj)) _ - (#R;Error ($_ text/append "Cannot get the fields of a non-object.")))) + (#R;Error ($_ text/compose "Cannot get the fields of a non-object.")))) (def: #export (get key json) {#;doc "A JSON object field getter."} @@ -114,10 +114,10 @@ (#R;Success value) #;None - (#R;Error ($_ text/append "Missing field \"" key "\" on object."))) + (#R;Error ($_ text/compose "Missing field \"" key "\" on object."))) _ - (#R;Error ($_ text/append "Cannot get field \"" key "\" of a non-object.")))) + (#R;Error ($_ text/compose "Cannot get field \"" key "\" of a non-object.")))) (def: #export (set key value json) {#;doc "A JSON object field setter."} @@ -127,18 +127,18 @@ (#R;Success (#Object (d;put key value obj))) _ - (#R;Error ($_ text/append "Cannot set field \"" key "\" of a non-object.")))) + (#R;Error ($_ text/compose "Cannot set field \"" key "\" of a non-object.")))) (do-template [ ] [(def: #export ( key json) - {#;doc (#;TextA ($_ text/append "A JSON object field getter for " "."))} + {#;doc (#;TextA ($_ text/compose "A JSON object field getter for " "."))} (-> Text JSON (R;Result )) (case (get key json) (#R;Success ( value)) (#R;Success value) (#R;Success _) - (#R;Error ($_ text/append "Wrong value type at key: " key)) + (#R;Error ($_ text/compose "Wrong value type at key: " key)) (#R;Error error) (#R;Error error)))] @@ -226,7 +226,7 @@ (do-template [ ] [(def: #export - {#;doc (#;TextA ($_ text/append "Reads a JSON value as " "."))} + {#;doc (#;TextA ($_ text/compose "Reads a JSON value as " "."))} (Reader ) (do p;Monad [head any] @@ -235,7 +235,7 @@ (wrap value) _ - (fail ($_ text/append "JSON value is not " ".")))))] + (fail ($_ text/compose "JSON value is not " ".")))))] [null Unit #Null "null"] [boolean Bool #Boolean "boolean"] @@ -245,7 +245,7 @@ (do-template [
]
   [(def: #export ( test)
-     {#;doc (#;TextA ($_ text/append "Asks whether a JSON value is a "  "."))}
+     {#;doc (#;TextA ($_ text/compose "Asks whether a JSON value is a "  "."))}
      (->  (Reader Bool))
      (do p;Monad
        [head any]
@@ -254,10 +254,10 @@
          (wrap (::  = test (
 value)))
 
          _
-         (fail ($_ text/append "JSON value is not "  ".")))))
+         (fail ($_ text/compose "JSON value is not "  ".")))))
 
    (def: #export ( test)
-     {#;doc (#;TextA ($_ text/append "Ensures a JSON value is a "  "."))}
+     {#;doc (#;TextA ($_ text/compose "Ensures a JSON value is a "  "."))}
      (->  (Reader Unit))
      (do p;Monad
        [head any]
@@ -266,10 +266,10 @@
          (let [value (
 value)]
            (if (::  = test value)
              (wrap [])
-             (fail ($_ text/append "Value mismatch: " ( test) "=/=" ( value)))))
+             (fail ($_ text/compose "Value mismatch: " ( test) "=/=" ( value)))))
 
          _
-         (fail ($_ text/append "JSON value is not a "  ".")))))]
+         (fail ($_ text/compose "JSON value is not a "  ".")))))]
 
   [boolean? boolean! Bool bool;Eq   (:: bool;Codec encode)   #Boolean "boolean" id]
   [number?  number!  Frac number;Eq (:: number;Codec encode) #Number  "number"  id]
@@ -347,7 +347,7 @@
           (fail error))
 
         _
-        (fail ($_ text/append "JSON object does not have field \"" field-name "\".")))
+        (fail ($_ text/compose "JSON object does not have field \"" field-name "\".")))
 
       _
       (fail "JSON value is not an object."))))
@@ -366,16 +366,16 @@
 
 (def: (show-array show-json elems)
   (-> (-> JSON Text) (-> Array Text))
-  ($_ text/append "["
+  ($_ text/compose "["
       (|> elems (Vector/map show-json) vector;to-list (text;join-with ","))
       "]"))
 
 (def: (show-object show-json object)
   (-> (-> JSON Text) (-> Object Text))
-  ($_ text/append "{"
+  ($_ text/compose "{"
       (|> object
           d;entries
-          (L/map (function [[key value]] ($_ text/append (show-string key) ":" (show-json value))))
+          (L/map (function [[key value]] ($_ text/compose (show-string key) ":" (show-json value))))
           (text;join-with ","))
       "}"))
 
@@ -436,8 +436,8 @@
              [mark (l;one-of "eE")
               signed?' (l;this? "-")
               offset (l;many l;decimal)]
-             (wrap ($_ text/append mark (if signed?' "-" "") offset))))]
-    (case (frac/decode ($_ text/append (if signed? "-" "") digits "." decimals exp))
+             (wrap ($_ text/compose mark (if signed?' "-" "") offset))))]
+    (case (frac/decode ($_ text/compose (if signed? "-" "") digits "." decimals exp))
       (#R;Error message)
       (p;fail message)
       
@@ -466,7 +466,7 @@
         (do @
           [escaped escaped~
            next-chars (recur [])]
-          (wrap ($_ text/append chars escaped next-chars)))
+          (wrap ($_ text/compose chars escaped next-chars)))
         (wrap chars))))
 
 (def: (kv~ json~)
-- 
cgit v1.2.3