ideas-1.2: Feedback services for intelligent tutoring systems

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

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 whereSource

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

Methods

newId :: a -> IdSource

concatId :: [a] -> IdSource

Instances

IsId Char 
IsId () 
IsId Id 
IsId a => IsId [a] 
IsId a => IsId (Maybe a) 
(IsId a, IsId b) => IsId (Either a b) 
(IsId a, IsId b) => IsId (a, b) 
(IsId a, IsId b, IsId c) => IsId (a, b, c) 

(#) :: (IsId a, IsId b) => a -> b -> IdSource

Appends two identifiers. Both parameters are overloaded.

Accessing (and changing) identifiers

class HasId a whereSource

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

Methods

getId :: a -> IdSource

changeId :: (Id -> Id) -> a -> aSource

unqualified :: HasId a => a -> StringSource

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 -> StringSource

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 -> aSource

Give a description for the current entity. If there already is a description, both strings are combined.

description :: HasId a => a -> StringSource

Get the current description.

showId :: HasId a => a -> StringSource

Show the identifier.

compareId :: HasId a => a -> a -> OrderingSource

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 whereSource

Type class for labeling entities with an identifier

Methods

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

Instances