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 #147

Merged
merged 1 commit 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
4 changes: 2 additions & 2 deletions examples/logic-tasks-examples.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ library
base >=4.7 && <5
, hspec
, logic-tasks
, output-monad
, output-blocks >=0.2
default-language: Haskell2010

test-suite verify-configs
Expand All @@ -51,5 +51,5 @@ test-suite verify-configs
, hspec
, logic-tasks
, logic-tasks-examples
, output-monad
, output-blocks >=0.2
default-language: Haskell2010
2 changes: 1 addition & 1 deletion examples/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.1.0.0
dependencies:
- base >= 4.7 && < 5
- logic-tasks
- output-monad
- output-blocks >= 0.2
- hspec

library:
Expand Down
2 changes: 1 addition & 1 deletion examples/src/Semantics/TruthTables/FindMistakes/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import LogicTasks.Config (
DecideConfig(..),
CnfConfig(..),
)
import Control.Monad.Output ( english, german, translations )
import Control.OutputCapable.Blocks (english, german, translations)
import Test.Hspec
import LogicTasks.Util (checkCnfConf)
import Util.VerifyConfig
Expand Down
2 changes: 1 addition & 1 deletion examples/src/Syntax/RemoveBrackets/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import Tasks.SynTree.Config (
SynTreeConfig(..),
)
import Control.Monad.Output (german, translations, english)
import Control.OutputCapable.Blocks (english, german, translations)
import Test.Hspec
import Util.VerifyConfig

-- Gewicht 0.33

Check failure on line 13 in examples/src/Syntax/RemoveBrackets/Config.hs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Gewicht` is not a recognized word. (unrecognized-spelling)
task02 :: SuperfluousBracketsConfig
task02 = SuperfluousBracketsConfig
{ syntaxTreeConfig = SynTreeConfig
Expand Down
4 changes: 2 additions & 2 deletions examples/src/Util/VerifyConfig.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}

Check failure on line 2 in examples/src/Util/VerifyConfig.hs

View workflow job for this annotation

GitHub Actions / Check Spelling

`NTypes` is not a recognized word. (unrecognized-spelling)
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Util.VerifyConfig where

import Control.Monad.Output (LangM, OutputMonad)
import Control.OutputCapable.Blocks (LangM, OutputCapable)
import Test.Hspec
import LogicTasks.Debug (checkConfigWith)
import Type.Reflection

verifyConfig :: a -> (forall m. OutputMonad m => a -> LangM m) -> Spec
verifyConfig :: a -> (forall m. OutputCapable m => a -> LangM m) -> Spec
verifyConfig config checker = itIsValid $ checkConfigWith config checker `shouldReturn` True

noChecker :: forall a. Typeable a => a -> Spec
Expand Down
4 changes: 2 additions & 2 deletions logic-tasks.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ library
, math-functions
, minisat-solver
, mtl
, output-monad
, output-blocks >=0.2
, parsec
, pretty-simple
, random
Expand Down Expand Up @@ -136,7 +136,7 @@ test-suite src-test
, math-functions
, minisat-solver
, mtl
, output-monad
, output-blocks >=0.2
, parsec
, pretty-simple
, random
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- wl-pprint-text
- parsec
- text
- output-monad
- output-blocks >= 0.2
- pretty-simple
- parsec
- latex-svg-image >= 0.2
Expand Down
2 changes: 1 addition & 1 deletion src/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import GHC.Generics
import Formula.Types
import Formula.Util
import Data.Map (Map)
import Control.Monad.Output (Language)
import Control.OutputCapable.Blocks (Language)



Expand Down
6 changes: 3 additions & 3 deletions src/Formula/Parsing/Delayed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Text.Parsec.String (Parser)
import Formula.Parsing (Parse(..))
import ParsingHelpers (fully)

import Control.Monad.Output (LangM, english, german, OutputMonad, Language)
import Control.OutputCapable.Blocks (LangM, Language, OutputCapable, english, german)
import Control.Monad.State (State)
import Data.Map (Map)

Expand All @@ -23,7 +23,7 @@ parseDelayed = parseDelayedRaw
parseDelayedRaw :: Parser b -> Delayed a -> Either ParseError b
parseDelayedRaw p (Delayed str) = parse p "(answer string)" str

withDelayed :: OutputMonad m => (a -> LangM m) -> Parser a -> Delayed a -> LangM m
withDelayed :: OutputCapable m => (a -> LangM m) -> Parser a -> Delayed a -> LangM m
withDelayed grade p d =
case parseDelayed (fully p) d of
Left err -> reject $ do
Expand All @@ -32,7 +32,7 @@ withDelayed grade p d =
Right x -> grade x

parseDelayedAndThen ::
(OutputMonad m, Parse a)
(OutputCapable m, Parse a)
=> (Maybe ParseError -> ParseError -> State (Map Language String) ())
-> Parser ()
-> (a -> LangM m)
Expand Down
4 changes: 2 additions & 2 deletions src/LogicTasks/Debug.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
module LogicTasks.Debug where

import Test.QuickCheck
import Control.Monad.Output.Generic
import Control.Monad.Output
import Control.OutputCapable.Blocks.Generic
import Control.OutputCapable.Blocks
import Text.Parsec
import Text.Parsec.String (Parser)
import Data.Maybe (isJust)
Expand Down
34 changes: 17 additions & 17 deletions src/LogicTasks/Helpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import qualified Data.ByteString as BS (readFile, writeFile)

import Control.Monad (when)
import Control.Monad.IO.Class (MonadIO (liftIO))
import Control.Monad.Output (
GenericOutputMonad (..),
import Control.OutputCapable.Blocks (
GenericOutputCapable (..),
LangM,
Language,
OutputMonad,
OutputCapable,
english,
german,
translate,
Expand All @@ -29,7 +29,7 @@ import System.Directory (doesFileExist)



extra :: OutputMonad m => Maybe (Map Language String) -> LangM m
extra :: OutputCapable m => Maybe (Map Language String) -> LangM m
extra (Just extraMap) = paragraph $ translate $ put extraMap
extra _ = pure ()

Expand All @@ -38,61 +38,61 @@ indexed = zipWith (\a b -> show a ++ ". " ++ b) ([1..] :: [Int])



instruct :: OutputMonad m => State (Map Language String) () -> LangM m
instruct :: OutputCapable m => State (Map Language String) () -> LangM m
instruct = paragraph . translate



focus :: OutputMonad m => String -> LangM m
focus :: OutputCapable m => String -> LangM m
focus = indent . code



example :: OutputMonad m => String -> State (Map Language String) () -> LangM m
example :: OutputCapable m => String -> State (Map Language String) () -> LangM m
example correct s = indent $ do
instruct s
code correct
pure ()


reject :: OutputMonad m => State (Map Language String) () -> LangM m
reject :: OutputCapable m => State (Map Language String) () -> LangM m
reject = refuse . indent . translate



clauseKey :: OutputMonad m => LangM m
clauseKey :: OutputCapable m => LangM m
clauseKey = do
keyHeading
negationKey
orKey
pure()

cnfKey :: OutputMonad m => LangM m
cnfKey :: OutputCapable m => LangM m
cnfKey = do
clauseKey
andKey
pure ()

formulaKey :: OutputMonad m => LangM m
formulaKey :: OutputCapable m => LangM m
formulaKey = do
keyHeading
basicOpKey
pure ()

basicOpKey :: OutputMonad m => LangM m
basicOpKey :: OutputCapable m => LangM m
basicOpKey = do
negationKey
andKey
orKey
pure()

keyHeading :: OutputMonad m => LangM m
keyHeading :: OutputCapable m => LangM m
keyHeading =
paragraph $ translate $ do
german "Beachten Sie dabei die folgenden möglichen Schreibweisen:"
english "You can use any of the following notations:"

andKey :: OutputMonad m => LangM m
andKey :: OutputCapable m => LangM m
andKey =
paragraph $ indent $ do
translate $ do
Expand All @@ -103,7 +103,7 @@ andKey =
english "/\\, and"
pure ()

orKey :: OutputMonad m => LangM m
orKey :: OutputCapable m => LangM m
orKey =
paragraph $ indent $ do
translate $ do
Expand All @@ -115,7 +115,7 @@ orKey =
pure ()


negationKey :: OutputMonad m => LangM m
negationKey :: OutputCapable m => LangM m
negationKey =
paragraph $ indent $ do
text "Negation:"
Expand All @@ -124,7 +124,7 @@ negationKey =
english "-, ~, not"
pure ()

arrowsKey :: OutputMonad m => LangM m
arrowsKey :: OutputCapable m => LangM m
arrowsKey = do
paragraph $ indent $ do
translate $ do
Expand Down
18 changes: 9 additions & 9 deletions src/LogicTasks/Semantics/Decide.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
module LogicTasks.Semantics.Decide where


import Control.Monad.Output (
GenericOutputMonad (..),
import Control.OutputCapable.Blocks (
GenericOutputCapable (..),
LangM,
OutputMonad,
OutputCapable,
english,
german,
translate,
Expand Down Expand Up @@ -40,7 +40,7 @@ genDecideInst DecideConfig{cnfConf = CnfConfig {baseConf = BaseConfig{..}, ..},



description :: OutputMonad m => DecideInst -> LangM m
description :: OutputCapable m => DecideInst -> LangM m
description DecideInst{..} = do
paragraph $ do
translate $ do
Expand Down Expand Up @@ -68,7 +68,7 @@ description DecideInst{..} = do
pure ()


verifyStatic :: OutputMonad m => DecideInst -> LangM m
verifyStatic :: OutputCapable m => DecideInst -> LangM m
verifyStatic DecideInst{..}
| isEmptyCnf cnf || hasEmptyClause cnf =
refuse $ indent $ translate $ do
Expand All @@ -93,7 +93,7 @@ verifyStatic DecideInst{..}



verifyQuiz :: OutputMonad m => DecideConfig -> LangM m
verifyQuiz :: OutputCapable m => DecideConfig -> LangM m
verifyQuiz DecideConfig{..}
| isOutside 1 100 percentageOfChanged =
refuse $ indent $ translate $ do
Expand All @@ -107,7 +107,7 @@ verifyQuiz DecideConfig{..}
start :: [Int]
start = []

preventIfSolutionExceedsTableSize :: OutputMonad m => Int -> Table -> LangM m
preventIfSolutionExceedsTableSize :: OutputCapable m => Int -> Table -> LangM m
preventIfSolutionExceedsTableSize solLen table = preventWithHint (solLen > tableLen)
(translate $ do
german "Lösung überschreitet nicht Anzahl der Zeilen?"
Expand All @@ -131,7 +131,7 @@ preventIfSolutionExceedsTableSize solLen table = preventWithHint (solLen > table
where
display = show diff

partialGrade :: OutputMonad m => DecideInst -> [Int] -> LangM m
partialGrade :: OutputCapable m => DecideInst -> [Int] -> LangM m
partialGrade DecideInst{..} sol = do
preventWithHint (null sol)
(translate $ do
Expand All @@ -148,7 +148,7 @@ partialGrade DecideInst{..} sol = do
pure ()


completeGrade :: OutputMonad m => DecideInst -> [Int] -> LangM m
completeGrade :: OutputCapable m => DecideInst -> [Int] -> LangM m
completeGrade DecideInst{..} sol = (if incorrect then refuse else id) $ do
printWithHint (solLen > acLen)
(translate $ do
Expand Down
16 changes: 8 additions & 8 deletions src/LogicTasks/Semantics/Fill.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
module LogicTasks.Semantics.Fill where


import Control.Monad.Output (
GenericOutputMonad (..),
import Control.OutputCapable.Blocks (
GenericOutputCapable (..),
LangM,
OutputMonad,
OutputCapable,
english,
german,
translate,
Expand Down Expand Up @@ -40,7 +40,7 @@ genFillInst FillConfig{ cnfConf = CnfConfig { baseConf = BaseConfig{..}, ..}, ..



description :: OutputMonad m => FillInst -> LangM m
description :: OutputCapable m => FillInst -> LangM m
description FillInst{..} = do
paragraph $ do
translate $ do
Expand Down Expand Up @@ -73,7 +73,7 @@ description FillInst{..} = do
pure ()


verifyStatic :: OutputMonad m => FillInst -> LangM m
verifyStatic :: OutputCapable m => FillInst -> LangM m
verifyStatic FillInst{..}
| isEmptyCnf cnf || hasEmptyClause cnf =
refuse $ indent $ translate $ do
Expand All @@ -96,7 +96,7 @@ verifyStatic FillInst{..}



verifyQuiz :: OutputMonad m => FillConfig -> LangM m
verifyQuiz :: OutputCapable m => FillConfig -> LangM m
verifyQuiz FillConfig{..}
| isOutside 1 100 percentageOfGaps =
refuse $ indent $ translate$ do
Expand All @@ -112,7 +112,7 @@ verifyQuiz FillConfig{..}
start :: [TruthValue]
start = []

partialGrade :: OutputMonad m => FillInst -> [TruthValue] -> LangM m
partialGrade :: OutputCapable m => FillInst -> [TruthValue] -> LangM m
partialGrade FillInst{..} sol = do
preventWithHint (solLen /= missingLen)
(translate $ do
Expand All @@ -130,7 +130,7 @@ partialGrade FillInst{..} sol = do
solLen = length boolSol
missingLen = length missing

completeGrade :: OutputMonad m => FillInst -> [TruthValue] -> LangM m
completeGrade :: OutputCapable m => FillInst -> [TruthValue] -> LangM m
completeGrade FillInst{..} sol = do
preventWithHint (notNull diff)
(translate $ do
Expand Down
Loading
Loading