on master help sign in
Hack to parse old JSON docs with primes
commiteebfe6a44bba686d4de0a10bf60dd2679f983c26 authorEvan Czaplicki <evancz@users.noreply.github.com> dateMon 10 Oct 2016, 14:40 (10 years ago) parent9a852e2
1 file changed+6−1
src/Elm/Compiler/Type.hs+6−1
src/Elm/Compiler/Type.hs+6−1
@@ -159,7 +159,7 @@ instance Json.FromJSON Type where
159159 case value of
160160 Json.String text ->
161161 either failure (return . fromRawType)
162− (Parse.iParse Type.expr (Text.unpack text))
162+ (Parse.iParse Type.expr (replacePrimes (Text.unpack text)))
163163
164164 Json.Object obj ->
165165 fromObject obj
@@ -168,6 +168,11 @@ instance Json.FromJSON Type where
168168 failure ()
169169
170170
171+replacePrimes :: String -> String
172+replacePrimes string =
173+ map (\c -> if c == '\'' then '_' else c) string
174+
175+
171176fromObject :: Json.Object -> Json.Parser Type
172177fromObject obj =
173178 do tag <- obj .: "tag"