on b23ff22 help sign in
52 lines 1.6 kB history raw
1{-# LANGUAGE DeriveDataTypeable #-}
2module SourceSyntax.Module where
4import Data.Data
5import Data.Binary
6import Data.List (intercalate)
7import qualified Data.Map as Map
8import Control.Applicative ((<$>), (<*>))
9import Control.Arrow (second)
11import SourceSyntax.Expression (LExpr)
12import SourceSyntax.Declaration
13import SourceSyntax.Type
14import System.FilePath (joinPath)
15import qualified Type.Type as Type
17data Module tipe var =
18 Module [String] Exports Imports [Declaration tipe var]
19 deriving (Show)
21type Exports = [String]
23type Imports = [(String, ImportMethod)]
24data ImportMethod = As String | Importing [String] | Hiding [String]
25 deriving (Eq, Ord, Show, Data, Typeable)
27data MetadataModule t v = MetadataModule {
28 names :: [String],
29 path :: FilePath,
30 exports :: [String],
31 imports :: [(String, ImportMethod)],
32 program :: LExpr t v,
33 types :: Map.Map String Type.Variable,
34 fixities :: [(Assoc, Int, String)],
35 aliases :: [(String, [String], Type)],
36 datatypes :: [ (String, [String], [(String,[Type])]) ],
37 foreignImports :: [(String, LExpr t v, String, Type)],
38 foreignExports :: [(String, String, Type)]
41type Interfaces = Map.Map String ModuleInterface
42type ADT = (String, [String], [(String,[Type])])
44data ModuleInterface = ModuleInterface {
45 iTypes :: Map.Map String Type,
46 iAdts :: [ADT],
47 iAliases :: [(String, [String], Type)]
48} deriving Show
50instance Binary ModuleInterface where
51 put modul = put (iTypes modul) >> put (iAdts modul) >> put (iAliases modul)
52 get = ModuleInterface <$> get <*> get <*> get