-- Type specifications for Edoc XML -> Haskell converter. module Language.Edoc.Xml2Hs.Type where -- Internal structures to define the Erlang module. They are based on the -- abovementioned DTD, but for simplification they are hand-coded rather than -- automatically produced from the DTD. Only few tags are of interest -- (mainly those related to toplevel typedefs, and argument types), the rest -- will be skipped. data EDocMod = EDocMod { em_name :: String ,em_args :: [String] ,em_tdefs :: [ETypeDef] ,em_funcs :: [EFunDecl]} deriving (Show) data ErlName = ErlName { en_app :: String ,en_mod :: String ,en_name :: String} deriving (Show) data ETypeDef = ETypeDef { td_ename :: ErlName ,td_argtypes :: [ErlType] ,td_type :: ErlType ,td_ldef :: [ELocDef]} deriving (Show) data EFunDecl = EFunDecl { ef_name :: String ,ef_arity :: Int ,ef_args :: [String] ,ef_tspec :: [ETypeSpec]} deriving (Show) data ETypeSpec = ETypeSpec { ts_ename :: ErlName ,ts_type :: ErlType ,ts_ldef :: [ELocDef]} deriving (Show) -- Few shortcuts here: -- 1. Union and Type are not made distinct since they are almost -- identical. Union just holds a list of unionized types (so -- there may be nested unions, despite the DTD). -- 2. In the Localdef definition, the first argument is also ErlType -- so there might be any type while the DTD says there may be only -- Typevar and Abstype. -- 3. In the Record definition, strings are used where DTD says to use -- Atoms; basically Strings and Atoms are equivalent in this case. -- 4. ENothing is to be used when the type element is absent, to avoid -- wrapping in Maybe. data ErlType = ETypeVar String | EAtom String | EInteger Integer | EFloat Double | ENil | EAny | ENum | EList ErlType | ETuple [ErlType] | EFun [ErlType] ErlType | ERecord String [(String, ErlType)] | EAbsType ErlName [ErlType] | EUnion [ErlType] | ENothing deriving (Show) data ELocDef = ELocDef ErlType ErlType deriving (Show)