-
Notifications
You must be signed in to change notification settings - Fork 1
TaskSettings
patritzenfeld edited this page Aug 5, 2025
·
6 revisions
The TaskSettings module defines configuration constants that are available to the rest of the task.
It also declares a mandatory validateSettings value, constrained by OutputCapable, which verifies that the settings make sense.
If something looks wrong, the function should abort; otherwise it should succeed quietly.
For a quick overview of OutputCapable, see OutputCapable.
Below is a minimal TaskSettings module to use as a starting point.
The example focuses on defining the dimensions of a table-based input form.
module TaskSettings where
import Control.OutputCapable.Blocks (
LangM,
OutputCapable,
english,
german,
indent,
refuse,
translate,
)
import Global (Name)
-- Constants to be used throughout the other modules
emptyColumns, staticColumns, totalColumns, rows :: Int
emptyColumns = 13
staticColumns = length [minBound .. maxBound :: Name]
totalColumns = staticColumns + emptyColumns
rows = 2^staticColumns
tableRequired, showSolution :: Bool
tableRequired = False
showSolution = True
-- Make sure none of the constants' set values are problematic
validateSettings :: OutputCapable m => LangM m
validateSettings
| emptyColumns < 5 = refuse $ indent $ translate $ do
english "Not enough empty columns to cover all hints (needs at least 5)."
german "Nicht genügend leeren Spalten um alle Hinweise umzusetzen (mindestens 5 benötigt)."
| totalColumns > 18 = refuse $ indent $ translate $ do
english $
"Table contains too many columns to display the input form correctly. " ++
"The maximum amount of columns is 18."
german $
"Die Tabelle enthält zu viele Spalten um das Eingabeformular korrekt anzuzeigen. " ++
"Es können maximal 18 Spalten eingestellt werden."
| otherwise = pure ()In most cases, you can copy this structure with only minor changes. A few things to keep in mind:
-
Constants defined here can be imported as usual in the other code segments.
This module is always loaded, just like
Global. -
Not every constant needs validation. For example,
tableRequiredandshowSolutionare not checked because they can’t conflict with anything else. -
You can implement
validateSettingshowever you like. If there is nothing to check, simply define it aspure ()so it always succeeds.
Author: patrick.ritzenfeld@uni-due.de