2module Metadata.Prelude (interfaces, add) where
4import qualified Data.Map as Map
5import qualified Control.Exception as E
8import AST.Module as Module
9import qualified Build.Interface as Interface
10import Build.Utils (getDataFile)
12add :: Bool -> Module exs body -> Module exs body
13add noPrelude (Module name path exs ims decls) =
14 Module name path exs (customIms ++ ims) decls
16 customIms = if noPrelude then [] else concatMap addModule prelude
18 addModule (n, method) = case lookup n ims of
19 Nothing -> [(n, method)]
20 Just (As _) -> [(n, method)]
23prelude :: [(String, ImportMethod)]
24prelude = text : string : map (\n -> (n, Module.open)) modules
26 string = ("String", Module.importing ["show"])
27 modules = [ "Basics", "Signal", "List", "Maybe", "Time", "Color"
28 , "Graphics.Element", "Graphics.Collage"
29 , "Native.Ports", "Native.Json"
31 text = ("Text", Module.importing textImports)
33 [ "toText", "leftAligned", "rightAligned", "centered", "justified"
34 , "plainText", "asText", "typeface", "monospace", "bold", "italic"
37interfaces :: Bool -> IO Interfaces
41 else safeReadDocs =<< getDataFile "interfaces.data"
43safeReadDocs :: FilePath -> IO Interfaces
45 E.catch (readDocs name) $ \err -> do
46 let _ = err :: IOError
47 hPutStrLn stderr $ unlines $
48 [ "Error reading types for standard library from file " ++ name
49 , " If you are using a stable version of Elm, please report an issue at"
50 , " <http://github.com/elm-lang/Elm/issues> specifying version numbers for"
51 , " Elm and your OS." ]
54readDocs :: FilePath -> IO Interfaces
56 interfaces <- Interface.load filePath
57 case mapM (Interface.isValid filePath) (interfaces :: [(String, Module.Interface)]) of
63 hPutStrLn stderr "No interfaces found in serialized Prelude!"
66 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