ideas-1.5: 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.

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 
IsId () Source 
IsId Id Source 
IsId a => IsId [a] Source 
IsId a => IsId (Maybe a) Source 
(IsId a, IsId b) => IsId (Either a b) Source 
(IsId a, IsId b) => IsId (a, b) Source 
(IsId a, IsId b, IsId c) => IsId (a, b, c) 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.

Methods

getId :: a -> Id Source

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

Methods

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