Ents

Plain source file: base/Modules/Ents.hs (2005-07-21)

Ents is imported by: AST4ModSys, NamesEntities, PPModules, WorkModule, ReAssocModule, ScopeModule, Pfe4Cmds, PfeDepCmds.

module Ents (module Ents, isValue) where

import TypedIds 
import HsIdent
import HsName(ModuleName)
import PosName(Id)
import Sets

-- interface of the module system to the concrete type of entities

type Entity = Ent Id 

-- The type of entities
data Ent n = Ent ModuleName (HsIdentI n) (IdTy n) deriving (Show,Read)

instance Eq n => Eq (Ent n) where
  Ent m1 i1 t1 == Ent m2 i2 t2 = m1==m2 && i1==i2 && namespace t1==namespace t2

instance Ord n => Ord (Ent n) where
  compare (Ent m1 i1 t1) (Ent m2 i2 t2) =
     compare (m1,i1,namespace t1) (m2,i2,namespace t2)

instance HasNameSpace (Ent n) where namespace = namespace . idTy
instance HasIdTy n (Ent n) where idTy (Ent _ _ ty) = ty

isCon (Ent _ (HsCon _) x) 
  | not (isAssertion x)   = namespace x == ValueNames
isCon _                   = False
 
owns (Ent m (HsCon n) (Type tyinfo)) = mkSet $
  map (mkCons . conName) (constructors tyinfo) ++
  map mkFields (fields tyinfo)
  where
    mkCons c      = Ent m (HsCon c) (ConstrOf n tyinfo)
    mkFields f    = Ent m (HsVar f) (FieldOf n tyinfo)
 
owns (Ent m (HsCon n) (Class cnt xs)) = mkSet (cvt `map` xs)
  where
  cvt x = Ent m (HsVar x) (MethodOf n cnt xs)

owns _ = emptySet


Index

(HTML for this module was generated on 2009-01-04. About the conversion tool.)