Skip to content

Description

Patrick Ritzenfeld edited this page Mar 9, 2026 · 8 revisions

This module is the most straightforward of the set. You only need to define the description function to produce a task description via OutputCapable.

Task Description

description has the following type signature:

description :: OutputCapable m => FilePath -> TaskData -> LangM m

This is mostly identical to the feedback functions used in Check. You'll string together output blocks to build a coherent task description. Avoid using aborting functions entirely. As before, the FilePath argument can be used to cache images or files, but can be ignored if unnecessary.

Available capabilities

You may add more constraints on m, just as explained in TaskData. Here's the full list of options:

  • MonadDiagrams
  • MonadGraphviz
  • MonadCache
  • MonadLatexSvg
  • MonadPlantUml
  • MonadWriteFile (deprecated; try using MonadCache instead)
  • MonadThrow

Example

Here's a simple example of a task description for calculating the GCD of two numbers:

{-# language ApplicativeDo #-}

description :: OutputCapable m => FilePath -> TaskData -> LangM m
description _ (a,b)= do
  paragraph $ do
    translate $ do
      english "Calculate the greatest common denominator of these numbers:"
      german "Berechnen Sie den größten gemeinsamen Nenner der Zahlen:"
    indent $ code $ show a
    indent $ code $ show b
    pure ()

  paragraph $
    translate $ do
      english "Use the Euclidean algorithm to do so "
      english "and keep track of the number of iterations performed."
      german "Verwenden Sie den Euklidischen Algorithmus "
      german "und notieren Sie sich die Anzahl der Iterationen."

  paragraph $
    translate $ do
      english "Submit your solution via the left input field. "
      english "Enter the amount of iterations into the right field."
      german "Geben Sie Ihre Lösung im linken Eingabefeld ab. "
      german "Die Anzahl der Iterationen geben Sie im rechten Feld ein."

  pure ()

💡 A common mistake here is incorrect indentation or forgetting do/pure. Every encapsulated block needs its own opening do and closing pure.

← Previous: Check | Next: Parse →

Clone this wiki locally