Maintainer | bastiaan.heeren@ou.nl |
---|---|
Stability | provisional |
Portability | portable (depends on ghc) |
Safe Haskell | None |
Language | Haskell98 |
Many entities of the Ideas framework carry an Id
for identification.
Identifiers have a hierarchical structure of an arbitrary depth (e.g.
algebra.equation
or a.b.c
). Valid symbols for identifiers are the
alpha-numerical characters, together with -
and _
. Each identifier
carries a description and a hash value for fast comparison.
Functionality for identifiers is provided by means of three type classes:
- Type class
IsId
for constructing identifiers - Type class
HasId
for accessing (and changing) the identifier of an entity. Instances of this type class must always have exactly one identifier (although this identifier can be empty). - Type class
Identify
for labeling entities with an identifier. Instances of this type class typically allow labels to appear at multiple locations within their structure.
The Id
datatype implements and re-exports the Monoid interface.
- data Id
- class IsId a where
- (#) :: (IsId a, IsId b) => a -> b -> Id
- class HasId a where
- unqualified :: HasId a => a -> String
- qualifiers :: HasId a => a -> [String]
- qualification :: HasId a => a -> String
- describe :: HasId a => String -> a -> a
- description :: HasId a => a -> String
- showId :: HasId a => a -> String
- compareId :: HasId a => a -> a -> Ordering
- class HasId a => Identify a where
- module Data.Monoid
Constructing identifiers
Abstract data type for identifiers with a hierarchical name, carrying a description. The data type provides a fast comparison implementation.
Type class IsId
for constructing identifiers. Examples are
newId "algebra.equation"
, newId ("a", "b", "c")
, and newId ()
for the empty identifier.
(#) :: (IsId a, IsId b) => a -> b -> Id infixr 8 Source
Appends two identifiers. Both parameters are overloaded.
Accessing (and changing) identifiers
Type classfor accessing (and changing) the identifier of an entity.
HasId Id Source | |
HasId ViewPackage Source | |
HasId Symbol Source | |
HasId Binding Source | |
HasId Service Source | |
HasId DomainReasoner Source | |
HasId (Ref a) Source | |
HasId (RewriteRule a) Source | |
HasId (Rule a) Source | |
HasId (Decl f) Source | |
HasId (LabeledStrategy a) Source | |
HasId (Predicate a) Source | |
HasId (Exercise a) Source | |
HasId (State a) Source | |
(HasId a, HasId b) => HasId (Either a b) Source | |
HasId (Isomorphism a b) Source | |
HasId (View a b) Source |
unqualified :: HasId a => a -> String Source
Get the unqualified part of the identifier (i.e., last string).
qualifiers :: HasId a => a -> [String] Source
Get the list of qualifiers of the identifier (i.e., everything but the last string).
qualification :: HasId a => a -> String Source
Get the qualified part of the identifier. If the identifier consists of
more than one part, the parts are separated by a period (
)..
describe :: HasId a => String -> a -> a Source
Give a description for the current entity. If there already is a description, both strings are combined.
description :: HasId a => a -> String Source
Get the current description.
compareId :: HasId a => a -> a -> Ordering Source
Compare two identifiers based on their names. Use compare
for a fast
ordering based on hash values.
Labeling with identifiers
module Data.Monoid