Commits

Maxim Moiseev committed b764372

'json' renamed to 'jarr' to make room for 'jobj'

  • Participants
  • Parent commits 12b9727

Comments (0)

Files changed (2)

File src/Common/JsonParser.fs

 module JsonParserImpl =
     open Newtonsoft.Json.Linq
 
-    type JsonParser<'a> =
-        JsonParser of (JToken[] -> ('a * JToken[]) list)
-        
-    let runParser (JsonParser p) tokens =
+    type JsonArrayParser<'a> =
+        JsonArrayParser of (JToken[] -> ('a * JToken[]) list)
+
+    let runParser (JsonArrayParser p) tokens =
         p tokens
-        
-        
+
     type JsonParserException(msg:string) =
         inherit System.Exception(msg)        
     
         | [(res, _)] -> res
         | _ -> raise <| System.NotSupportedException("This should not normally happen")
 
-    type JsonBuilder() = 
+    type JsonArrayBuilder() = 
         member this.Return(x) =
-            JsonParser (fun ts -> [(x, ts)])
+            JsonArrayParser (fun ts -> [(x, ts)])
         member this.Fail() =
-            JsonParser (fun _ -> [])
+            JsonArrayParser (fun _ -> [])
         member this.Zero() =
-            JsonParser (fun _ -> [])
+            JsonArrayParser (fun _ -> [])
         member this.Bind(p, f) =
-            JsonParser (fun ts ->
+            JsonArrayParser (fun ts ->
                 match runParser p ts with
                 | [(r, ts')] -> runParser (f r) ts'
                 | _ -> []
 module JsonParser =             
     open JsonParserImpl
     
-    let json = JsonBuilder()
+    let jarr = JsonArrayBuilder()
     
     let at idx =
-        JsonParser (fun ts ->
+        JsonArrayParser (fun ts ->
             if ts.Length <> 0 && idx < ts.Length then
                 [(ts.[idx]), ts]
             else
             |> getParsingResult
     
     let parseOrDefault parser defaultValue =
-        JsonParser (fun ts ->
+        JsonArrayParser (fun ts ->
             match runParser parser ts with
             | [] -> [(defaultValue, ts)]
             | res -> res
     let (<|>) = parseOrDefault
     
     let parseOrFail condition parser =
-        JsonParser (fun ts ->
+        JsonArrayParser (fun ts ->
             if condition then
                 runParser parser ts
             else
     let (<?>) = parseOrFail
     
     let tokenAtAs idx converter =
-        json {
+        jarr {
             let! t = at idx
             return (converter t)
         }
     open Newtonsoft.Json.Linq
 
     let singleItemParser =        
-        json {
+        jarr {
             let! a =  int <@> 0
             let! c = (string <@> 2) <|> "default"
             return (a,c)

File src/Common/Parsers.fs

     open Tools
 
     let friend =
-        json {
+        jarr {
             let! id = int64 <@> 0
             let! name = string' <@> 1
             let! photo = string' <@> 2
         }
         
     let status =
-        json {
+        jarr {
             let! id = string <@> 0
             let! userId = int64 <@> 1
             let! (_, statusId) = (parseComplexId << string) <@> 0
         }
         
     let photo =
-        json {
+        jarr {
             let! id = string <@> 0
             let! (ownerId, photoId) = (parseComplexId << string) <@> 0
             let! thumbnailUrl = string' <@> 1
         }
     
     let userDescription =
-        json {
+        jarr {
             let! userId = (int64 << anyString) <@> 0
             let! name = string' <@> 1 <|> String.Empty
             let! photoUrl = anyString <@> 2 <|> String.Empty
         }
         
     let message =
-        json {
+        jarr {
             let! messageId = (int64 << anyString) <@> 0
             let! timestamp = parseTimestamp <@> 1
             let! text = (childToken 0 >> string) <@> 2