1module SourceSyntax.Module where
4import Data.List (intercalate)
5import qualified Data.Map as Map
6import Control.Applicative ((<$>), (<*>))
7import Control.Arrow (second)
9import SourceSyntax.Expression (LExpr)
10import SourceSyntax.Declaration
11import SourceSyntax.Type
12import System.FilePath (joinPath)
13import Control.Monad (liftM)
15import qualified Elm.Internal.Version as Version
18 Module [String] Exports Imports [Declaration tipe var]
21type Exports = [String]
23type Imports = [(String, ImportMethod)]
24data ImportMethod = As String | Importing [String] | Hiding [String]
25 deriving (Eq, Ord, Show)
27instance Binary ImportMethod where
28 put (As s) = do put (0 :: Word8)
31 put (Importing ss) = do put (1 :: Word8)
34 put (Hiding ss) = do put (2 :: Word8)
37 get = do tag <- getWord8
40 1 -> liftM Importing get
42 _ -> error "Error reading valid ImportMethod type from serialized string"
44data MetadataModule t v = MetadataModule {
48 imports :: [(String, ImportMethod)],
50 types :: Map.Map String Type,
51 fixities :: [(Assoc, Int, String)],
52 aliases :: [(String, [String], Type)],
53 datatypes :: [ (String, [String], [(String,[Type])]) ],
54 foreignImports :: [(String, LExpr t v, String, Type)],
55 foreignExports :: [(String, String, Type)]
58type Interfaces = Map.Map String ModuleInterface
59type ADT = (String, [String], [(String,[Type])])
61data ModuleInterface = ModuleInterface {
62 iVersion :: Version.Version,
63 iTypes :: Map.Map String Type,
64 iImports :: [(String, ImportMethod)],
66 iAliases :: [(String, [String], Type)],
67 iFixities :: [(Assoc, Int, String)]
70metaToInterface metaModule =
72 { iVersion = Version.elmVersion
73 , iTypes = types metaModule
74 , iImports = imports metaModule
75 , iAdts = datatypes metaModule
76 , iAliases = aliases metaModule
77 , iFixities = fixities metaModule
80instance Binary ModuleInterface where
81 get = ModuleInterface <$> get <*> get <*> get <*> get <*> get <*> get
91instance Binary Assoc where
92 get = do n <- getWord8
97 _ -> error "Error reading valid associativity from serialized string"
99 put assoc = putWord8 $ case assoc of { L -> 0 ; N -> 1 ; R -> 2 }
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