Skip to content

Evaluation and reduction sheets

Martijn Schrage edited this page Mar 2, 2017 · 1 revision

The evaluation and reduction sheets ($instantiation/src/Evaluator.hs and $instantiation/src/Reducer.hs) specify how the document is mapped onto the enriched document and back. Both sheets are Haskell modules, which must declare an instance of a multi-parameter type class (resp. EvaluationSheet and ReductionSheet). For the evaluation sheet, the class is:

class EvaluationSheet doc enr clip | doc -> clip where
  evaluationSheet ::
    LayerStateEval doc clip -> DocumentLevel doc clip -> EnrichedDocLevel enr doc -> 
    EditDocument' doc enr node clip token -> DocumentLevel doc clip -> 
    IO (EditEnrichedDoc' doc enr node clip token, LayerStateEval doc clip, DocumentLevel doc clip)
  evaluationSheetSimpleIO :: LayerStateEval doc clip -> doc -> enr -> doc -> 
    IO (enr, LayerStateEval doc clip, doc)
  evaluationSheetSimple   :: LayerStateEval doc clip -> doc -> enr -> doc -> 
    (enr, LayerStateEval doc clip, doc)
  evaluationSheetSimplest :: doc -> enr

In order to declare an instance, it is only necessary to define one of the member functions. The simplest option is to declare the function evaluationSheetSimples, which directly maps the document on the enriched document. A bit more powerful is evaluationSheetSimple, which also defines a mapping from document to enriched document, but it gets the layer state and the old values of the document and the enriched document as additional parameters. Besides the enriched document, the function also returns the updated layer state and the new value for the document. An IO version of this function is evaluationSheetSimpleIO. Finally, evaluationSheet is the most powerful as it gets all parameters that exist at the evaluation layer. It is not very likely, however that this function will be needed.

For the reduction sheet, the situation is dual, with the exception that reductionSheet does not get the edit operation parameter, since this will always be a SetEnr (in the evaluation sheet, it may be either SetDoc' or EvaluateDoc'). The class is:

class ReductionSheet doc enr clip | doc -> clip where
  reductionSheet :: 
    LayerStateEval doc clip -> EnrichedDocLevel enr doc -> DocumentLevel doc clip ->
    EnrichedDocLevel enr doc ->
    IO (EditDocument doc enr node clip token, LayerStateEval doc clip, EnrichedDocLevel enr doc)
  reductionSheetSimpleIO :: LayerStateEval doc clip -> enr -> doc -> enr ->
    IO (doc, LayerStateEval doc clip, enr)
  reductionSheetSimple   :: LayerStateEval doc clip -> enr -> doc -> enr ->
    (doc, LayerStateEval doc clip, enr)
  reductionSheetSimplest :: enr -> doc

-- Main.MartijnSchrage - 23 Jan 2008

Clone this wiki locally