2module Metadata.Prelude (interfaces, add) where
4import qualified Data.Map as Map
5import qualified Control.Exception as E
8import SourceSyntax.Module
9import qualified Build.Interface as Interface
10import Build.Utils (getDataFile)
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 = map ((,) "String") [ As "String", Importing ["show"] ]
27 modules = [ "Basics", "Signal", "List", "Maybe", "Time", "Color"
28 , "Graphics.Element", "Graphics.Collage"
29 , "Native.Ports", "Native.Json"
32interfaces :: Bool -> IO Interfaces
36 else safeReadDocs =<< getDataFile "interfaces.data"
38safeReadDocs :: FilePath -> IO Interfaces
40 E.catch (readDocs name) $ \err -> do
41 let _ = err :: IOError
42 hPutStrLn stderr $ unlines $
43 [ "Error reading types for standard library from file " ++ name
44 , " If you are using a stable version of Elm, please report an issue at"
45 , " <http://github.com/evancz/Elm/issues> specifying version numbers for"
46 , " Elm and your OS." ]
49readDocs :: FilePath -> IO Interfaces
51 interfaces <- Interface.load filePath
52 case mapM (Interface.isValid filePath) (interfaces :: [(String, ModuleInterface)]) of
58 hPutStrLn stderr "No interfaces found in serialized Prelude!"
61 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