Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to output-blocks #6

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/hlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ name: Haskell Linter
on:
push:
branches: ['**']
pull_request:
branches:
- main

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: 'Set up HLint'
uses: rwe/actions-hlint-setup@v1
uses: haskell-actions/hlint-setup@v2
with:
version: '3.5'

- name: 'Run HLint'
uses: rwe/actions-hlint-run@v2
uses: haskell-actions/hlint-run@v2
with:
path: '["src/", "test/"]'
fail-on: suggestion
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- QuickCheck
- extra
- parsec
- output-monad
- output-blocks >= 0.2
default-extensions:
- DuplicateRecordFields
- OverloadedLabels
Expand Down
21 changes: 11 additions & 10 deletions src/TermTasks/Direct.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import qualified Data.Map as M (fromAscList)
import Data.List (nub, sort, (\\))
import Control.Applicative (Alternative)
import Control.Monad (when)
import Control.Monad.Output (
GenericOutputMonad (indent, itemizeM, latex, refuse, text, paragraph),
import Control.OutputCapable.Blocks (
ArticleToUse (DefiniteArticle),
GenericOutputCapable (indent, itemizeM, latex, refuse, text, paragraph),
LangM,
OutputMonad,
OutputCapable,
Rated,
continueOrAbort,
english,
Expand All @@ -35,7 +36,7 @@ import qualified Tasks.CertainSignature as CertainSignature



description :: OutputMonad m => SigInstance -> LangM m
description :: OutputCapable m => SigInstance -> LangM m
description SigInstance{..} = do
text1
indent $ traverse_ (latex . mathifySignature . show) symbols
Expand All @@ -58,7 +59,7 @@ genInst c@Certain{..} = do
return $ SigInstance { symbols, terms, correct, moreFeedback, showSolution }


verifyInst :: OutputMonad m => SigInstance -> LangM m
verifyInst :: OutputCapable m => SigInstance -> LangM m
verifyInst SigInstance{..}
| notInRange =
refuse $ indent $ translate $ do
Expand Down Expand Up @@ -89,7 +90,7 @@ verifyInst SigInstance{..}



verifyCertain :: OutputMonad m => Certain -> LangM m
verifyCertain :: OutputCapable m => Certain -> LangM m
verifyCertain Certain{..}
| doubleDef =
refuse $ indent $ translate $ do
Expand Down Expand Up @@ -128,7 +129,7 @@ verifyCertain Certain{..}



verifyBase :: OutputMonad m => Base -> LangM m
verifyBase :: OutputCapable m => Base -> LangM m
verifyBase Base{..}
| negativeAmounts =
refuse $ indent $ translate $ do
Expand Down Expand Up @@ -165,7 +166,7 @@ start = []



partialGrade :: OutputMonad m => SigInstance -> [Int] -> LangM m
partialGrade :: OutputCapable m => SigInstance -> [Int] -> LangM m
partialGrade SigInstance{..} sol
| invalidIndex =
refuse $ indent $ translate $ do
Expand All @@ -177,7 +178,7 @@ partialGrade SigInstance{..} sol
invalidIndex = any (`notElem` [1 .. length terms]) nubSol

completeGrade
:: (Alternative m, OutputMonad m)
:: (Alternative m, OutputCapable m)
=> SigInstance
-> [Int]
-> Rated m
Expand Down Expand Up @@ -216,7 +217,7 @@ completeGrade SigInstance {..} sol = do
(second (`elem` correct) . dupe)
[1 .. length terms]
paragraph (text "")
x <- multipleChoice what solution matching sol
x <- multipleChoice DefiniteArticle what solution matching sol
pure x
where
assert = continueOrAbort showSolution
Expand Down
14 changes: 7 additions & 7 deletions src/TermTasks/Messages.hs
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{-# LANGUAGE FlexibleContexts #-}
module TermTasks.Messages where

import Control.Monad.Output (
GenericOutputMonad (..),
import Control.OutputCapable.Blocks (
GenericOutputCapable (..),
LangM,
OutputMonad,
OutputCapable,
english,
german,
translate
)

text1 :: OutputMonad m => LangM m
text1 :: OutputCapable m => LangM m
text1 = paragraph $ translate $ do
german "Betrachten Sie die folgenden Deklarationen von Konstanten und Operationen:"
english "Consider the following declarations of constants and operations:"



text2 :: OutputMonad m => LangM m
text2 :: OutputCapable m => LangM m
text2 = paragraph $ translate $ do
german "Entscheiden Sie für die folgenden Terme, ob sie korrekt im Sinne der oben gegebenen Deklarationen sind:"
english "Decide for the following terms whether or not they are correct according to the declarations given above:"

text3 :: OutputMonad m => LangM m
text3 :: OutputCapable m => LangM m
text3 = paragraph $ translate $ do
german "Bitte geben Sie Ihre Antwort in Form einer Liste von Zahlen an, die alle korrekten Terme enthält."
english "Please state your answer by giving a list of numbers, indicating all correct terms."

text4 :: OutputMonad m => LangM m
text4 :: OutputCapable m => LangM m
text4 = paragraph $ translate $ do
german "Zum Beispiel [1, 2] würde bedeuten, dass nur die Terme 1. und 2. von den angegebenen korrekt sind."
english "For example, [1, 2] would indicate that only terms 1. and 2. of the given ones are correct."
8 changes: 4 additions & 4 deletions src/TermTasks/Perturbed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
module TermTasks.Perturbed where


import Control.Monad.Output (
GenericOutputMonad (indent, refuse),
import Control.OutputCapable.Blocks (
GenericOutputCapable (indent, refuse),
LangM,
OutputMonad,
OutputCapable,
english,
german,
translate,
Expand All @@ -33,7 +33,7 @@
shuffle arguments
>>= \arguments' ->
let symbol' = remapSymbols symbol
in return $ (elemIndex symbol' symbols ,) $

Check warning on line 36 in src/TermTasks/Perturbed.hs

View workflow job for this annotation

GitHub Actions / run

Suggestion in perturbConfig in module TermTasks.Perturbed: Evaluate ▫︎ Found: "(elemIndex symbol' symbols,)\n $ Symbol\n {symbol = symbol', arguments = map remapTypes arguments',\n result = remapTypes result}" ▫︎ Perhaps: "(elemIndex symbol' symbols, \n Symbol\n {symbol = symbol', arguments = map remapTypes arguments',\n result = remapTypes result})"

Check warning on line 36 in src/TermTasks/Perturbed.hs

View workflow job for this annotation

GitHub Actions / run

Suggestion in perturbConfig in module TermTasks.Perturbed: Evaluate ▫︎ Found: "(elemIndex symbol' symbols,)\n $ Symbol\n {symbol = symbol', arguments = map remapTypes arguments',\n result = remapTypes result}" ▫︎ Perhaps: "(elemIndex symbol' symbols, \n Symbol\n {symbol = symbol', arguments = map remapTypes arguments',\n result = remapTypes result})"
Symbol { symbol = symbol'
, arguments = map remapTypes arguments'
, result = remapTypes result }
Expand All @@ -42,7 +42,7 @@
genInst $ Certain {signatures = Signature sigs', root = map remapTypes <$> root, baseConf}


verifyPerturbed :: OutputMonad m => Perturbed -> LangM m
verifyPerturbed :: OutputCapable m => Perturbed -> LangM m
verifyPerturbed Perturbed{..}
| emptyInput =
refuse $ indent $ translate $ do
Expand Down
6 changes: 3 additions & 3 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ packages:
- .
extra-deps:

- git: https://github.com/fmidue/output-monad.git
commit: 1f3edf2cd4a13ca6cb62e24a57f6da66ef6894d0
- git: https://github.com/fmidue/output-blocks.git
commit: f2418656472b9c32bde06ec3b916fe6d749d0290
subdirs:
- output-monad
- output-blocks
4 changes: 2 additions & 2 deletions term-tasks.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ library
, base
, containers
, extra
, output-monad
, output-blocks >=0.2
, parsec
, split
default-language: Haskell2010
Expand Down Expand Up @@ -88,7 +88,7 @@ test-suite term-tasks-test
, containers
, extra
, hspec
, output-monad
, output-blocks >=0.2
, parsec
, split
, term-tasks
Expand Down
Loading