@@ -15,9 +15,11 @@ import Data.Argonaut (Json, JsonDecodeError(..), caseJson, decodeJson, isNull)
1515import Data.Array as Array
1616import Data.Array.ST as STArray
1717import Data.Either (Either(..), note)
18+import Data.Enum (toEnum)
1819import Data.Foldable (intercalate)
1920import Data.Int as Int
2021import Data.Maybe (Maybe(..))
22+import Data.String.CodePoints (CodePoint, fromCodePointArray)
2123import Data.String.CodeUnits as SCU
2224import Data.Traversable (traverse)
2325import Data.Tuple (Tuple(..))
@@ -264,7 +266,7 @@ decodeLiteral dec json = do
264266 "NumberLiteral" ->
265267 LitNumber <$> getField decodeNumber obj "value"
266268 "StringLiteral" ->
267− LitString <$> getField decodeString obj "value"
269+ LitString <$> getField decodeStringLiteral obj "value"
268270 "CharLiteral" -> do
269271 str <- getField decodeString obj "value"
270272 LitChar <$> note (TypeMismatch "Char") do
@@ -358,12 +360,22 @@ decodeJArray = caseJson fail fail fail fail Right fail
358360 fail :: forall a. a -> JsonDecode (Array Json)
359361 fail _ = Left $ TypeMismatch "Array"
360362
363+decodeStringLiteral :: Json -> JsonDecode String
364+decodeStringLiteral json =
365+ decodeString json <|> \_ -> map fromCodePointArray (decodeCodePointArray json) <|> \_ -> throwError (TypeMismatch "StringLiteral")
366+
361367decodeString :: Json -> JsonDecode String
362368decodeString = caseJson fail fail fail Right fail fail
363369 where
364370 fail :: forall a. a -> JsonDecode String
365371 fail _ = Left $ TypeMismatch "String"
366372
373+decodeCodePointArray :: Json -> JsonDecode (Array CodePoint)
374+decodeCodePointArray = decodeArray decodeCodePoint
375+
376+decodeCodePoint :: Json -> JsonDecode CodePoint
377+decodeCodePoint = note (TypeMismatch "CodePoint") <<< toEnum <=< decodeInt
378+
367379decodeNumber :: Json -> JsonDecode Number
368380decodeNumber = caseJson fail fail Right fail fail fail
369381 where