Safe Haskell | None |
---|
- class Feature a expr | a -> expr where
- featureName :: a -> Text
- featureArgs :: a -> [Decl]
- featureResult :: a -> Typ
- featurePre :: a -> [Clause expr]
- featurePost :: a -> [Clause expr]
- featureIsFrozen :: a -> Bool
- featureRename :: a -> RenameClause -> a
- data FeatureEx expr = forall a . Feature a expr => FeatureEx a
- wrapSomeFeature :: (forall f. Feature f expr => f -> b) -> SomeFeature body expr -> b
- class Feature a expr => ClassFeature a body expr | a -> expr, a -> body where
- allFeatures :: AbsClas body expr -> [a]
- findFeature :: AbsClas body expr -> Text -> Maybe a
- findFeature' :: (SomeFeature body expr -> Maybe a) -> AbsClas body expr -> Text -> Maybe a
- constToAttr :: Constant exp -> Attribute Expr
- allAttributes :: AbsClas body exp -> [Attribute exp]
- allRoutines :: AbsClas body exp -> [AbsRoutine body exp]
- allConstants :: AbsClas body exp -> [Constant exp]
- allHelper :: Getting (HashMap k (ExportedFeature a)) (FeatureMap body exp) t (HashMap k (ExportedFeature a)) b -> AbsClas body exp -> [a]
- allCreates :: AbsClas body exp -> [Text]
- allAttributeDecls :: AbsClas body exp -> [Decl]
- allConstantDecls :: AbsClas body exp -> [Decl]
- allInherited :: AbsClas body exp -> [InheritClause]
- allInheritedTypes :: AbsClas body exp -> [Typ]
- isCreateName :: Text -> AbsClas body exp -> Bool
- toRoutineMb :: SomeFeature t t1 -> Maybe (AbsRoutine t t1)
- toAttrMb :: SomeFeature t t1 -> Maybe (Attribute t1)
- toConstMb :: SomeFeature t t1 -> Maybe (Constant t1)
- updFeatureMap :: AbsClas body exp -> FeatureMap body exp -> AbsClas body exp
- updFeatBody :: RoutineBody a -> PosAbsStmt b -> RoutineBody b
- mapRoutinesM :: (Applicative m, Monad m) => (AbsRoutine body exp -> m (AbsRoutine body exp)) -> FeatureMap body exp -> m (FeatureMap body exp)
- mapAttributes :: (Attribute exp -> Attribute exp) -> FeatureMap body exp -> FeatureMap body exp
- mapAttributesM :: (Monad m, Applicative m) => (Attribute exp -> m (Attribute exp)) -> FeatureMap body exp -> m (FeatureMap body exp)
- mapContract :: (Clause exp1 -> Clause exp) -> Contract exp1 -> Contract exp
- mapExprs :: (AbsRoutine body exp -> AbsRoutine body' exp') -> (Constant exp -> Constant exp') -> (Clause exp -> Clause exp') -> FeatureMap body exp -> FeatureMap body' exp'
- classMapAttributes :: (Attribute exp -> Attribute exp) -> AbsClas body exp -> AbsClas body exp
- classMapAttributesM :: (Applicative m, Monad m) => (Attribute exp -> m (Attribute exp)) -> AbsClas body exp -> m (AbsClas body exp)
- classMapRoutines :: (AbsRoutine body exp -> AbsRoutine body exp) -> AbsClas body exp -> AbsClas body exp
- classMapRoutinesM :: (Applicative m, Monad m) => (AbsRoutine body exp -> m (AbsRoutine body exp)) -> AbsClas body exp -> m (AbsClas body exp)
- classMapConstants :: (Constant exp -> Constant exp) -> AbsClas body exp -> AbsClas body exp
- classMapExprs :: (AbsRoutine body exp -> AbsRoutine body' exp') -> (Clause exp -> Clause exp') -> (Constant exp -> Constant exp') -> AbsClas body exp -> AbsClas body' exp'
- makeRoutineIs :: SomeFeature body Expr -> SomeFeature EmptyBody Expr
- makeAttributeI :: Attribute exp -> Attribute Expr
- clasInterface :: AbsClas body Expr -> ClasInterface
- makeRoutineI :: AbsRoutine body Expr -> RoutineI
- clasMap :: [AbsClas body exp] -> Map ClassName (AbsClas body exp)
- attrMap :: AbsClas body exp -> Map Text Typ
- findRoutine :: Clas -> Text -> Maybe Routine
- findOperator :: AbsClas body Expr -> Text -> Int -> Maybe (AbsRoutine body Expr)
- findSomeFeature :: AbsClas body expr -> Text -> Maybe (SomeFeature body expr)
- findFeatureEx :: AbsClas body expr -> Text -> Maybe (FeatureEx expr)
- findRoutineInt :: ClasInterface -> Text -> Maybe RoutineI
- findAttrInt :: AbsClas body expr -> Text -> Maybe (Attribute expr)
- findConstantInt :: AbsClas body Expr -> Text -> Maybe (Constant Expr)
- fullName :: AbsClas body exp -> RoutineI -> Text
- fullNameStr :: Text -> Text -> Text
- genericStubs :: AbsClas body exp -> [AbsClas body' exp']
- makeGenericStub :: Generic -> AbsClas body exp
- renameDecl :: RenameClause -> Decl -> Decl
- renameType :: RenameClause -> Typ -> Typ
- renameAll :: [RenameClause] -> AbsClas body exp -> AbsClas body exp
- undefineName :: Text -> AbsClas body exp -> AbsClas body exp
- undefineAll :: InheritClause -> AbsClas body exp -> AbsClas body exp
- mergeableClass :: AbsClas body exp -> Bool
- mergeClass :: AbsClas body exp -> AbsClas body exp -> AbsClas body exp
- mergeClasses :: [AbsClas body exp] -> AbsClas body exp
- fmMapKeys :: (Text -> Text) -> FeatureMap body exp -> FeatureMap body exp
- fmKeyFilter :: (Text -> Bool) -> FeatureMap body exp -> FeatureMap body exp
- fmUnion :: FeatureMap body exp -> FeatureMap body exp -> FeatureMap body exp
- fmEmpty :: FeatureMap body exp
- fmUnions :: [FeatureMap body exp] -> FeatureMap body exp
- argMap :: RoutineWithBody a -> Map Text Typ
- localMap :: RoutineWithBody a -> Map Text Typ
- routineDecls :: AbsRoutine (RoutineBody exp1) exp -> [Decl]
- opAlias :: BinOp -> Text
- equalityOp :: BinOp -> Bool
- unOpAlias :: IsString a => UnOp -> a
- classToType :: AbsClas body exp -> Typ
- isBasic :: Typ -> Bool
- intBits :: [Integer]
- typeBounds :: Typ -> (Integer, Integer)
- isBooleanType :: Typ -> Bool
- isIntegerType :: Typ -> Bool
- isNaturalType :: Typ -> Bool
- isRealType :: Typ -> Bool
- isCharType :: Typ -> Bool
- isInTypeNames :: [ClassName] -> Typ -> Bool
- integerTypeNames :: [Text]
- naturalTypeNames :: [Text]
- realTypeNames :: [Text]
- charTypeNames :: [Text]
- classNameType :: Typ -> Text
- intType :: Typ
- boolType :: Typ
- realType :: Typ
- charType :: Typ
- stringType :: Typ
- anyType :: Typ
- namedType :: ClassName -> Typ
- insertDecl :: Decl -> Map Text Typ -> Map Text Typ
- declsToMap :: [Decl] -> Map Text Typ
- newVar :: ProcDecl -> Proc
Documentation
class Feature a expr | a -> expr whereSource
A Feature
can provide its name, arguments, contract, etc.
featureName :: a -> TextSource
The name of the feature.
featureArgs :: a -> [Decl]Source
Argument declarations.
featureResult :: a -> TypSource
Result type.
featurePre :: a -> [Clause expr]Source
Precondition.
featurePost :: a -> [Clause expr]Source
Postconditions.
featureIsFrozen :: a -> BoolSource
Whether the feature is frozen (can't be redefined).
featureRename :: a -> RenameClause -> aSource
Transform the feature given a renaming clause.
Feature (Constant expr) expr | |
Feature (Attribute expr) expr | |
Feature (FeatureEx expr) expr | |
Feature (AbsRoutine body expr) expr | |
Feature (SomeFeature body expr) expr |
An existential type to aggregate all features (routines, attributes, constants) together.
Feature (FeatureEx expr) expr | |
ClassFeature (FeatureEx expr) body expr |
wrapSomeFeature :: (forall f. Feature f expr => f -> b) -> SomeFeature body expr -> bSource
Wrap up SomeFeature
class Feature a expr => ClassFeature a body expr | a -> expr, a -> body whereSource
A way to extract each type of feature from a class.
allFeatures :: AbsClas body expr -> [a]Source
A list of all this class' features of the given type.
findFeature :: AbsClas body expr -> Text -> Maybe aSource
Find this kind of feature in a class
ClassFeature (Constant expr) body expr | |
ClassFeature (Attribute expr) body expr | |
ClassFeature (FeatureEx expr) body expr | |
ClassFeature (AbsRoutine body expr) body expr |
findFeature' :: (SomeFeature body expr -> Maybe a) -> AbsClas body expr -> Text -> Maybe aSource
constToAttr :: Constant exp -> Attribute ExprSource
Convert a constant into an attribute.
Extracting data from a class.
allAttributes :: AbsClas body exp -> [Attribute exp]Source
Fetch attributes from all feature clauses.
allRoutines :: AbsClas body exp -> [AbsRoutine body exp]Source
Fetch routines from all feature clauses.
allConstants :: AbsClas body exp -> [Constant exp]Source
Fetch contants from all feature clauses.
allHelper :: Getting (HashMap k (ExportedFeature a)) (FeatureMap body exp) t (HashMap k (ExportedFeature a)) b -> AbsClas body exp -> [a]Source
allCreates :: AbsClas body exp -> [Text]Source
Fetch creation routines from all feature clauses.
allAttributeDecls :: AbsClas body exp -> [Decl]Source
Fetch attribute declarations from all feature clauses.
allConstantDecls :: AbsClas body exp -> [Decl]Source
Fetch constant declarations from all feature clauses.
allInherited :: AbsClas body exp -> [InheritClause]Source
All inheritance clauses.
allInheritedTypes :: AbsClas body exp -> [Typ]Source
All inherited classes, as types.
isCreateName :: Text -> AbsClas body exp -> BoolSource
Determine if a name is in the creation clause of a class.
SomeFeature
predicates, extractors.
toRoutineMb :: SomeFeature t t1 -> Maybe (AbsRoutine t t1)Source
toAttrMb :: SomeFeature t t1 -> Maybe (Attribute t1)Source
toConstMb :: SomeFeature t t1 -> Maybe (Constant t1)Source
Class modification
Setting members of a class.
updFeatureMap :: AbsClas body exp -> FeatureMap body exp -> AbsClas body expSource
Set the feature clause of a class.
updFeatBody :: RoutineBody a -> PosAbsStmt b -> RoutineBody bSource
Update a routine body.
Mapping features of a class
mapRoutinesM :: (Applicative m, Monad m) => (AbsRoutine body exp -> m (AbsRoutine body exp)) -> FeatureMap body exp -> m (FeatureMap body exp)Source
These functions will update a class or feature clause with a transformation function.
Map a transformation function over the routines in a class, replacing the old routines with the transformed versions within a feature clause. mapRoutines f = Map.map (over exportFeat (onlyRoutine f))
Monadic version of mapRoutines
.
mapAttributes :: (Attribute exp -> Attribute exp) -> FeatureMap body exp -> FeatureMap body expSource
Map a transformation function over the attributes in a class, replacing the old attributes with the transformed versions within a feature clause.
mapAttributesM :: (Monad m, Applicative m) => (Attribute exp -> m (Attribute exp)) -> FeatureMap body exp -> m (FeatureMap body exp)Source
Monadic version of mapAttributes
.
mapContract :: (Clause exp1 -> Clause exp) -> Contract exp1 -> Contract expSource
Map a transformation function over the constants in a class, replacing the old constants with the transformed versions within a feature clause. mapConstants f = Map.map (over exportFeat (onlyConst f))
Map a transformation function over the contracts in a class, replacing the old contracts with the transformed versions within a feature clause.
mapExprs :: (AbsRoutine body exp -> AbsRoutine body' exp') -> (Constant exp -> Constant exp') -> (Clause exp -> Clause exp') -> FeatureMap body exp -> FeatureMap body' exp'Source
Map a transformation function over all expressions in a class. A transformation for features, constants, and attributes must be given as if the type of expressions changes (ie, with a typecheck) then all expressions types must change together.
classMapAttributes :: (Attribute exp -> Attribute exp) -> AbsClas body exp -> AbsClas body expSource
Map a transformation function over the attributes in a class, replacing the old attributes with the transformed versions within a class.
classMapAttributesM :: (Applicative m, Monad m) => (Attribute exp -> m (Attribute exp)) -> AbsClas body exp -> m (AbsClas body exp)Source
Monadic version of classMapAttributes
.
classMapRoutines :: (AbsRoutine body exp -> AbsRoutine body exp) -> AbsClas body exp -> AbsClas body expSource
Map a transformation function over the routines in a class, replacing the old routines with the transformed versions within a class.
classMapRoutinesM :: (Applicative m, Monad m) => (AbsRoutine body exp -> m (AbsRoutine body exp)) -> AbsClas body exp -> m (AbsClas body exp)Source
Monadic version of classMapRoutines
.
classMapConstants :: (Constant exp -> Constant exp) -> AbsClas body exp -> AbsClas body expSource
Map a transformation function over the constants in a class, replacing the old constants with the transformed versions within a class.
classMapExprs :: (AbsRoutine body exp -> AbsRoutine body' exp') -> (Clause exp -> Clause exp') -> (Constant exp -> Constant exp') -> AbsClas body exp -> AbsClas body' exp'Source
Map a transformation function over all expressions in a class. A transformation for features, constants, and attributes must be given as if the type of expressions changes (ie, with a typecheck) then all expressions types must change together. This is performed on every feature clause in a class.
Interface construction
makeRoutineIs :: SomeFeature body Expr -> SomeFeature EmptyBody ExprSource
Strip the body from a routine.
makeAttributeI :: Attribute exp -> Attribute ExprSource
Strip the contracts from an attribute.
clasInterface :: AbsClas body Expr -> ClasInterfaceSource
Strip the bodies from all features.
makeRoutineI :: AbsRoutine body Expr -> RoutineISource
Strip the bodies and rescue clause from a routine.
Map construction
clasMap :: [AbsClas body exp] -> Map ClassName (AbsClas body exp)Source
Turn a list of classes into a map indexed by the class names.
attrMap :: AbsClas body exp -> Map Text TypSource
Extract a map of attribute names to types given a class.
Search
findOperator :: AbsClas body Expr -> Text -> Int -> Maybe (AbsRoutine body Expr)Source
Find an operator (symbol sequence) in a class.
findSomeFeature :: AbsClas body expr -> Text -> Maybe (SomeFeature body expr)Source
Find the sum-type for all features.
findFeatureEx :: AbsClas body expr -> Text -> Maybe (FeatureEx expr)Source
Find an existential FeatureEx
.
findRoutineInt :: ClasInterface -> Text -> Maybe RoutineISource
Find a routine by name.
findAttrInt :: AbsClas body expr -> Text -> Maybe (Attribute expr)Source
Find an attribute in a class by name.
findConstantInt :: AbsClas body Expr -> Text -> Maybe (Constant Expr)Source
Find a constant by name in a class.
fullName :: AbsClas body exp -> RoutineI -> TextSource
Given a class and a routine, given a unique name.
fullNameStr :: Text -> Text -> TextSource
Given to string construct a unique combination.
genericStubs :: AbsClas body exp -> [AbsClas body' exp']Source
Given a class, create a list of generic classes for the formal generic parameters of the class.
makeGenericStub :: Generic -> AbsClas body expSource
Given a generic, construct a class for the generic.
Inheritance utilities
renameDecl :: RenameClause -> Decl -> DeclSource
Rename a declaration.
renameType :: RenameClause -> Typ -> TypSource
Rename a type, in the case of a like-type.
renameAll :: [RenameClause] -> AbsClas body exp -> AbsClas body expSource
Rename everything in a class.
undefineName :: Text -> AbsClas body exp -> AbsClas body expSource
Undefine a single feature in a class.
undefineAll :: InheritClause -> AbsClas body exp -> AbsClas body expSource
Undefine every specified name for a class.
mergeableClass :: AbsClas body exp -> BoolSource
Specifies whether a class can be merged with another.
mergeClass :: AbsClas body exp -> AbsClas body exp -> AbsClas body expSource
Merge two classes, combining invariants and feature clauses.
mergeClasses :: [AbsClas body exp] -> AbsClas body expSource
Merge a list of classes.
Feature Map functions
fmMapKeys :: (Text -> Text) -> FeatureMap body exp -> FeatureMap body expSource
fmKeyFilter :: (Text -> Bool) -> FeatureMap body exp -> FeatureMap body expSource
fmUnion :: FeatureMap body exp -> FeatureMap body exp -> FeatureMap body expSource
fmEmpty :: FeatureMap body expSource
fmUnions :: [FeatureMap body exp] -> FeatureMap body expSource
Routine level utilities
routineDecls :: AbsRoutine (RoutineBody exp1) exp -> [Decl]Source
Give the declarations of a routine's locals.
opAlias :: BinOp -> TextSource
Operator aliases for user-level operators, ie, not including =, =, ~, and ~
equalityOp :: BinOp -> BoolSource
Test if the binary operator is an equality operator.
Type utilities
classToType :: AbsClas body exp -> TypSource
Convert a class into its type.
Whether a type is basic (where basic meaning its an integer, natural, real or boolean).
typeBounds :: Typ -> (Integer, Integer)Source
The bounds on the range of values a integer or natural type can take.
isBooleanType :: Typ -> BoolSource
Boolean type test.
isIntegerType :: Typ -> BoolSource
Integer type test.
isNaturalType :: Typ -> BoolSource
Natural number type test.
isRealType :: Typ -> BoolSource
Real number type test.
isCharType :: Typ -> BoolSource
Character type test.
isInTypeNames :: [ClassName] -> Typ -> BoolSource
integerTypeNames :: [Text]Source
List of integer type names (ie, INTEGER_32).
naturalTypeNames :: [Text]Source
List of integer type names (ie, NATURAL_32).
realTypeNames :: [Text]Source
List of integer type names (ie, REAL_64).
charTypeNames :: [Text]Source
List of integer type names (ie, CHARACTER_8).
classNameType :: Typ -> TextSource
Given a type give the name of the class as a string.
The default string type.
Declaration
insertDecl :: Decl -> Map Text Typ -> Map Text TypSource
Insert a declaration into a string-type map.