Skip to content

fmidue/modelling-tasks

Repository files navigation

modelling-tasks Haskell CI

This repository contains exercise tasks for modelling lecture contents.

The diagram types covered are

  • Activity diagram (UML)
  • Class diagram (UML)
  • Object diagram (UML)
  • Petri net

Compatibility

On Windows, you may have to replace MiniSat by SAT4J in the Capabilities.Alloy module.

Generating instances in GHCi

Task types usually have a consistent naming scheme. Therefore it should be possible to perform the following steps accordingly for all other tasks in order to test a certain task. The example here is for NameCdError (i.e. module Modelling.CdOd.NameCdError). For German versions, change English to German.

stack ghci --stack-yaml=stack-examples.yaml
:m +Control.OutputCapable.Blocks Control.OutputCapable.Blocks.Generic
inst <- nameCdErrorGenerate defaultNameCdErrorConfig 0 0
runLangMReport (return ()) (>>) (nameCdErrorTask "/tmp/" inst) >>= \(Just (), x) -> (x English :: IO ())
runLangMReport (return ()) (>>) (nameCdErrorSyntax inst NameCdErrorAnswer {reason = 'b', dueTo = [1,2,4]}) >>= \(Just (), x) -> (x English :: IO ())
runLangMReport (return ()) (>>) (nameCdErrorEvaluation inst NameCdErrorAnswer {reason = 'b', dueTo = [1,2,4]}) >>= \(r, x) -> (x English :: IO ()) >> return r :: IO (Maybe Rational)

For running all steps at once in ghci, the following approach is also possible:

:m +Control.OutputCapable.Blocks.Debug System.Random Text.Parsec
let getLines = init <$> getLines' where getLines' = do { x <- getLine; if null x then pure [] else (\l -> x ++ '\n' : l) <$> getLines' }
testTask English (randomRIO (0,1000) >>= nameCdErrorGenerate defaultNameCdErrorConfig 0) (nameCdErrorTask "/tmp/") nameCdErrorSyntax nameCdErrorEvaluation (either (error . show) id . parse parseNameCdErrorAnswer "" <$> getLines)

Please also note that the ..Task, ..Syntax, and ..Evaluation functions sometimes require arguments for a directory (above "/tmp/") and sometimes don't.

In order to view configurations and instances formatted more nicely, you may use pPrint, e.g.:

:m + Text.Pretty.Simple
pPrint defaultNameCdErrorConfig
inst <- nameCdErrorGenerate defaultNameCdErrorConfig 0 0
pPrint inst