Skip to content

Commit

Permalink
express function in terms of flex utility
Browse files Browse the repository at this point in the history
  • Loading branch information
patritzenfeld committed Feb 5, 2025
1 parent 8976ee6 commit f91ac41
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
30 changes: 11 additions & 19 deletions src/Formula/Parsing/Delayed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Formula.Parsing.Delayed (
withDelayed,
displayParseError,
withDelayedSucceeding,
parseDelayedAbortOrProcess,
withDelayedReportOrSucceed,
parseDelayedWithAndThen,
complainAboutMissingParenthesesIfNotFailingOn,
complainAboutWrongNotation
Expand All @@ -23,14 +23,10 @@ import Control.OutputCapable.Blocks (
ReportT,
english,
german,
indent,
translate
)
import Control.OutputCapable.Blocks.Generic (
toAbort,
)
import Control.Monad.State (State)
import Data.Map (Map)
import FlexTask.Generic.Parse (parseWithOrReport)

import LogicTasks.Helpers (reject)
import Formula.Parsing.Delayed.Internal (Delayed(..))
Expand Down Expand Up @@ -61,24 +57,20 @@ displayParseError err = do
english $ show err
german $ show err

parseDelayedAbortOrProcess ::
withDelayedReportOrSucceed ::
(Monad m, OutputCapable (ReportT o m))
=> Parser a
-> (Maybe ParseError -> ParseError -> State (Map Language String) ())
-> Parser ()
-> String
-> (a -> LangM' (ReportT o m) b)
-> LangM' (ReportT o m) b
parseDelayedAbortOrProcess p messaging fallBackParser answerString whatToDo =
case parseDelayed (fully p) asDelayed of
Left err -> toAbort (indent $ translate $
messaging (either Just (const Nothing) $
parseDelayedRaw (fully fallBackParser) asDelayed)
err
)
Right x -> whatToDo x
where
asDelayed = delayed answerString
-> LangM' (ReportT o m) a
withDelayedReportOrSucceed p messaging fallBackParser =
parseWithOrReport
(parseDelayed (fully p))
(\answer -> messaging (either Just (const Nothing) $
parseDelayedRaw (fully fallBackParser) answer)
)
. delayed

parseDelayedWithAndThen ::
OutputCapable m
Expand Down
4 changes: 2 additions & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ extra-deps:
- minisat-solver-0.1
- latex-svg-image-0.2
- git: https://github.com/fmidue/output-blocks.git
commit: d155aa5a1978329ae5ab936a78ab6dd5f74919c2
commit: 77dd77fcbb8084a31c6633089605f7654af12ece
subdirs:
- output-blocks
- git: https://github.com/fmidue/flex-tasks.git
commit: b50ab20b157f3009835da0206e4bfe8872de6f81
commit: 26c7fe304007e78f669519bb62ae374cc85281a9
subdirs:
- flex-tasks
- flex-tasks-processing

0 comments on commit f91ac41

Please sign in to comment.