2module Metadata.Prelude (interfaces, add) where
4import qualified Data.Map as Map
5import qualified Control.Exception as E
6import qualified Paths_Elm as Path
9import SourceSyntax.Module
10import qualified Build.Interface as Interface
12add :: Bool -> Module def -> Module def
13add noPrelude (Module name exs ims decls) = Module name exs (customIms ++ ims) decls
15 customIms = if noPrelude then [] else concatMap addModule prelude
17 addModule (n, method) = case lookup n ims of
18 Nothing -> [(n, method)]
19 Just (As _) -> [(n, method)]
22prelude :: [(String, ImportMethod)]
23prelude = string : text ++ map (\n -> (n, Hiding [])) modules
25 text = map ((,) "Text") [ As "Text", Hiding ["link", "color", "height"] ]
26 string = ("String", As "String")
27 modules = [ "Basics", "Signal", "List", "Maybe", "Time", "Prelude"
28 , "Graphics.Element", "Color", "Graphics.Collage", "Native.Ports" ]
30interfaces :: Bool -> IO Interfaces
33 then return $ Map.empty
34 else safeReadDocs =<< Path.getDataFileName "interfaces.data"
36safeReadDocs :: FilePath -> IO Interfaces
38 E.catch (readDocs name) $ \err -> do
39 let _ = err :: IOError
40 hPutStrLn stderr $ unlines $
41 [ "Error reading types for standard library from file " ++ name
42 , " If you are using a stable version of Elm, please report an issue at"
43 , " <http://github.com/evancz/Elm/issues> specifying version numbers for"
44 , " Elm and your OS." ]
47readDocs :: FilePath -> IO Interfaces
49 interfaces <- Interface.load filePath
50 case mapM (Interface.isValid filePath) (interfaces :: [(String, ModuleInterface)]) of
56 hPutStrLn stderr "No interfaces found in serialized Prelude!"
59 Right ifaces -> return $ Map.fromList ifaces
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list