on master help sign in
Merge pull request #331 from jsl/327_fix_invalid_interface_map

Fix deserialization of interfaces in Prelude

commit4b480a90107faf4beb75bf6abb181bbfb8296ddc authorEvan Czaplicki <info@elm-lang.org> dateThu 7 Nov 2013, 10:02 (13 years ago) parentb3d53579ae1825
1 file changed+4−9
compiler/Metadata/Prelude.hs+4−9
compiler/Metadata/Prelude.hs+4−9
@@ -47,9 +47,10 @@ safeReadDocs name =
4747 , " and specify your versions of Elm and your OS" ]
4848 exitFailure
4949
50−firstModuleInterface :: Interfaces -> Either String (String, ModuleInterface)
50+firstModuleInterface :: [(String, ModuleInterface)] ->
51+ Either String (String, ModuleInterface)
5152firstModuleInterface interfaces =
52− case Map.toList interfaces of
53+ case interfaces of
5354 [] -> Left "No interfaces found in serialized Prelude!"
5455 iface:_ -> Right iface
5556
@@ -69,10 +70,4 @@ readDocs filePath = do
6970 hPutStrLn stderr err
7071 exitFailure
7172
72− -- Unwrapping the Right value here is safe since the whole above chain
73− -- returns a Right value. The toList/fromList is necessary because of a
74− -- problem with looking up keys in the Map after deserialization. Example
75− -- at https://gist.github.com/jsl/7294493.
76− -- TODO: try switching to Data.ByteString.Lazy.Char8
77− (Right ifaces, _) ->
78− return $ Map.fromList $ Map.toList ifaces
73+ (Right ifaces, _) -> return $ Map.fromList ifaces