2013-06-14 01:00:24 +00:00
|
|
|
{-# LANGUAGE DeriveDataTypeable #-}
|
|
|
|
module SourceSyntax.Module where
|
|
|
|
|
|
|
|
import Data.Data
|
2013-07-21 04:08:08 +00:00
|
|
|
import Data.Binary
|
2013-06-14 01:00:24 +00:00
|
|
|
import Data.List (intercalate)
|
2013-07-16 19:42:37 +00:00
|
|
|
import qualified Data.Map as Map
|
2013-07-21 04:08:08 +00:00
|
|
|
import Control.Applicative ((<$>), (<*>))
|
2013-07-16 19:42:37 +00:00
|
|
|
|
|
|
|
import SourceSyntax.Expression
|
|
|
|
import SourceSyntax.Declaration
|
|
|
|
import SourceSyntax.Type
|
2013-06-14 01:00:24 +00:00
|
|
|
import System.FilePath (joinPath)
|
2013-07-21 04:08:08 +00:00
|
|
|
import qualified Type.Type as Type
|
2013-06-14 01:00:24 +00:00
|
|
|
|
2013-06-14 03:25:00 +00:00
|
|
|
data Module tipe var =
|
2013-07-16 19:42:37 +00:00
|
|
|
Module [String] Exports Imports [Declaration tipe var]
|
2013-06-14 03:25:00 +00:00
|
|
|
deriving (Show)
|
2013-06-14 01:00:24 +00:00
|
|
|
|
|
|
|
type Exports = [String]
|
|
|
|
|
|
|
|
type Imports = [(String, ImportMethod)]
|
|
|
|
data ImportMethod = As String | Importing [String] | Hiding [String]
|
|
|
|
deriving (Eq, Ord, Show, Data, Typeable)
|
|
|
|
|
2013-07-16 19:42:37 +00:00
|
|
|
data MetadataModule t v = MetadataModule {
|
2013-07-17 17:24:40 +00:00
|
|
|
names :: [String],
|
|
|
|
path :: FilePath,
|
|
|
|
exports :: [String],
|
|
|
|
imports :: [(String, ImportMethod)],
|
2013-07-19 16:02:24 +00:00
|
|
|
program :: LExpr t v,
|
2013-07-21 04:08:08 +00:00
|
|
|
types :: Map.Map String Type.Variable,
|
2013-07-17 17:24:40 +00:00
|
|
|
fixities :: [(Assoc, Int, String)],
|
|
|
|
aliases :: [(String, [String], Type)],
|
|
|
|
datatypes :: [ (String, [String], [(String,[Type])]) ],
|
2013-07-16 19:42:37 +00:00
|
|
|
foreignImports :: [(String, LExpr t v, String, Type)],
|
|
|
|
foreignExports :: [(String, String, Type)]
|
|
|
|
}
|
2013-07-21 04:08:08 +00:00
|
|
|
|
2013-07-21 20:50:48 +00:00
|
|
|
type Interfaces = Map.Map String ModuleInterface
|
|
|
|
|
2013-07-21 04:08:08 +00:00
|
|
|
data ModuleInterface = ModuleInterface {
|
|
|
|
iTypes :: Map.Map String Type,
|
2013-07-21 20:50:48 +00:00
|
|
|
iAdts :: [(String, [String], [(String,[Type])])]
|
2013-07-21 04:08:08 +00:00
|
|
|
} deriving Show
|
|
|
|
|
|
|
|
instance Binary ModuleInterface where
|
|
|
|
put modul = put (iTypes modul) >> put (iAdts modul)
|
|
|
|
get = ModuleInterface <$> get <*> get
|