Merge pull request #331 from jsl/327_fix_invalid_interface_map
Fix deserialization of interfaces in Prelude
This commit is contained in:
commit
4b480a9010
1 changed files with 4 additions and 9 deletions
|
@ -47,9 +47,10 @@ safeReadDocs name =
|
||||||
, " and specify your versions of Elm and your OS" ]
|
, " and specify your versions of Elm and your OS" ]
|
||||||
exitFailure
|
exitFailure
|
||||||
|
|
||||||
firstModuleInterface :: Interfaces -> Either String (String, ModuleInterface)
|
firstModuleInterface :: [(String, ModuleInterface)] ->
|
||||||
|
Either String (String, ModuleInterface)
|
||||||
firstModuleInterface interfaces =
|
firstModuleInterface interfaces =
|
||||||
case Map.toList interfaces of
|
case interfaces of
|
||||||
[] -> Left "No interfaces found in serialized Prelude!"
|
[] -> Left "No interfaces found in serialized Prelude!"
|
||||||
iface:_ -> Right iface
|
iface:_ -> Right iface
|
||||||
|
|
||||||
|
@ -69,10 +70,4 @@ readDocs filePath = do
|
||||||
hPutStrLn stderr err
|
hPutStrLn stderr err
|
||||||
exitFailure
|
exitFailure
|
||||||
|
|
||||||
-- Unwrapping the Right value here is safe since the whole above chain
|
(Right ifaces, _) -> return $ Map.fromList ifaces
|
||||||
-- returns a Right value. The toList/fromList is necessary because of a
|
|
||||||
-- problem with looking up keys in the Map after deserialization. Example
|
|
||||||
-- at https://gist.github.com/jsl/7294493.
|
|
||||||
-- TODO: try switching to Data.ByteString.Lazy.Char8
|
|
||||||
(Right ifaces, _) ->
|
|
||||||
return $ Map.fromList $ Map.toList ifaces
|
|
||||||
|
|
Loading…
Reference in a new issue