ideas-1.7: Feedback services for intelligent tutoring systems

Maintainerbastiaan.heeren@ou.nl
Stabilityprovisional
Portabilityportable (depends on ghc)
Safe HaskellNone
LanguageHaskell98

Ideas.Common.Id

Contents

Description

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.

Synopsis

Constructing identifiers

data Id Source #

Abstract data type for identifiers with a hierarchical name, carrying a description. The data type provides a fast comparison implementation.

Instances

Eq Id Source # 

Methods

(==) :: Id -> Id -> Bool #

(/=) :: Id -> Id -> Bool #

Ord Id Source # 

Methods

compare :: Id -> Id -> Ordering #

(<) :: Id -> Id -> Bool #

(<=) :: Id -> Id -> Bool #

(>) :: Id -> Id -> Bool #

(>=) :: Id -> Id -> Bool #

max :: Id -> Id -> Id #

min :: Id -> Id -> Id #

Read Id Source # 
Show Id Source # 

Methods

showsPrec :: Int -> Id -> ShowS #

show :: Id -> String #

showList :: [Id] -> ShowS #

Semigroup Id Source # 

Methods

(<>) :: Id -> Id -> Id #

sconcat :: NonEmpty Id -> Id #

stimes :: Integral b => b -> Id -> Id #

Monoid Id Source # 

Methods

mempty :: Id #

mappend :: Id -> Id -> Id #

mconcat :: [Id] -> Id #

Arbitrary Id Source # 

Methods

arbitrary :: Gen Id #

shrink :: Id -> [Id] #

HasId Id Source # 

Methods

getId :: Id -> Id Source #

changeId :: (Id -> Id) -> Id -> Id Source #

IsId Id Source # 

Methods

newId :: Id -> Id Source #

concatId :: [Id] -> Id Source #

class IsId a where Source #

Type class IsId for constructing identifiers. Examples are newId "algebra.equation", newId ("a", "b", "c"), and newId () for the empty identifier.

Minimal complete definition

newId

Methods

newId :: a -> Id Source #

concatId :: [a] -> Id Source #

Instances

IsId Char Source # 

Methods

newId :: Char -> Id Source #

concatId :: [Char] -> Id Source #

IsId () Source # 

Methods

newId :: () -> Id Source #

concatId :: [()] -> Id Source #

IsId Id Source # 

Methods

newId :: Id -> Id Source #

concatId :: [Id] -> Id Source #

IsId a => IsId [a] Source # 

Methods

newId :: [a] -> Id Source #

concatId :: [[a]] -> Id Source #

IsId a => IsId (Maybe a) Source # 

Methods

newId :: Maybe a -> Id Source #

concatId :: [Maybe a] -> Id Source #

(IsId a, IsId b) => IsId (Either a b) Source # 

Methods

newId :: Either a b -> Id Source #

concatId :: [Either a b] -> Id Source #

(IsId a, IsId b) => IsId (a, b) Source # 

Methods

newId :: (a, b) -> Id Source #

concatId :: [(a, b)] -> Id Source #

(IsId a, IsId b, IsId c) => IsId (a, b, c) Source # 

Methods

newId :: (a, b, c) -> Id Source #

concatId :: [(a, b, c)] -> Id Source #

(#) :: (IsId a, IsId b) => a -> b -> Id infixr 8 Source #

Appends two identifiers. Both parameters are overloaded.

Accessing (and changing) identifiers

class HasId a where Source #

Type classfor accessing (and changing) the identifier of an entity.

Minimal complete definition

getId, changeId

Methods

getId :: a -> Id Source #

changeId :: (Id -> Id) -> a -> a Source #

Instances

HasId Id Source # 

Methods

getId :: Id -> Id Source #

changeId :: (Id -> Id) -> Id -> Id Source #

HasId ViewPackage Source # 
HasId Symbol Source # 

Methods

getId :: Symbol -> Id Source #

changeId :: (Id -> Id) -> Symbol -> Symbol Source #

HasId Binding Source # 

Methods

getId :: Binding -> Id Source #

changeId :: (Id -> Id) -> Binding -> Binding Source #

HasId Service Source # 

Methods

getId :: Service -> Id Source #

changeId :: (Id -> Id) -> Service -> Service Source #

HasId DomainReasoner Source # 
HasId (Predicate a) Source # 

Methods

getId :: Predicate a -> Id Source #

changeId :: (Id -> Id) -> Predicate a -> Predicate a Source #

HasId (Constraint a) Source # 

Methods

getId :: Constraint a -> Id Source #

changeId :: (Id -> Id) -> Constraint a -> Constraint a Source #

HasId (Ref a) Source # 

Methods

getId :: Ref a -> Id Source #

changeId :: (Id -> Id) -> Ref a -> Ref a Source #

HasId (RewriteRule a) Source # 
HasId (Rule a) Source # 

Methods

getId :: Rule a -> Id Source #

changeId :: (Id -> Id) -> Rule a -> Rule a Source #

HasId (Decl f) Source # 

Methods

getId :: Decl f -> Id Source #

changeId :: (Id -> Id) -> Decl f -> Decl f Source #

HasId (Dynamic a) Source # 

Methods

getId :: Dynamic a -> Id Source #

changeId :: (Id -> Id) -> Dynamic a -> Dynamic a Source #

HasId (Leaf a) Source # 

Methods

getId :: Leaf a -> Id Source #

changeId :: (Id -> Id) -> Leaf a -> Leaf a Source #

HasId (LabeledStrategy a) Source # 
HasId (Exercise a) Source # 

Methods

getId :: Exercise a -> Id Source #

changeId :: (Id -> Id) -> Exercise a -> Exercise a Source #

HasId (State a) Source # 

Methods

getId :: State a -> Id Source #

changeId :: (Id -> Id) -> State a -> State a Source #

(HasId a, HasId b) => HasId (Either a b) Source # 

Methods

getId :: Either a b -> Id Source #

changeId :: (Id -> Id) -> Either a b -> Either a b Source #

HasId (Isomorphism a b) Source # 

Methods

getId :: Isomorphism a b -> Id Source #

changeId :: (Id -> Id) -> Isomorphism a b -> Isomorphism a b Source #

HasId (View a b) Source # 

Methods

getId :: View a b -> Id Source #

changeId :: (Id -> Id) -> View a b -> 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.

showId :: HasId a => a -> String Source #

Show the identifier.

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

class HasId a => Identify a where Source #

Type class for labeling entities with an identifier

Minimal complete definition

(@>)

Methods

(@>) :: IsId n => n -> a -> a Source #

Instances

Identify (Predicate a) Source # 

Methods

(@>) :: IsId n => n -> Predicate a -> Predicate a Source #

Identify (Isomorphism a b) Source # 

Methods

(@>) :: IsId n => n -> Isomorphism a b -> Isomorphism a b Source #

Identify (View a b) Source # 

Methods

(@>) :: IsId n => n -> View a b -> View a b Source #

(<>) :: Semigroup a => a -> a -> a infixr 6 #

An associative operation.

(a <> b) <> c = a <> (b <> c)

If a is also a Monoid we further require

(<>) = mappend