minizinc-process 0.1.2.0 → 0.1.2.1
raw patch · 3 files changed
+20/−13 lines, 3 files
Files
- CHANGELOG.md +4/−0
- minizinc-process.cabal +1/−2
- src/Process/Minizinc.hs +15/−11
CHANGELOG.md view
@@ -2,6 +2,10 @@ ## Unreleased changes +## 0.1.2.1 -- 2020-11-08++* Handle case where final result is partial.+ ## 0.1.2.0 -- 2020-11-08 * Pass a parsed JSON Value rather than the Value in ResultHandler.
minizinc-process.cabal view
@@ -4,7 +4,7 @@ -- http://haskell.org/cabal/users-guide/ name: minizinc-process-version: 0.1.2.0+version: 0.1.2.1 synopsis: A set of helpers to call minizinc models. description: MiniZinc is a language and a toolchain to solve discrete optimization problems. This package provides simple wrappers around the MiniZinc executable to pass inputs and read outputs. homepage: https://github.com/lucasdicioccio/minizinc-process#readme@@ -42,4 +42,3 @@ , stringsearch , text default-language: Haskell2010-
src/Process/Minizinc.hs view
@@ -158,16 +158,7 @@ -> b -> ResultHandler answer b -> IO b- go out parsebuf buf v1 handler- | ByteString.null buf = do- eof <- hIsEOF out- if eof- then- inputFinished v1- else do- dat <- ByteString.hGetLine out- go out parsebuf dat v1 handler- | otherwise = do+ go out parsebuf buf v1 handler = do case parsebuf buf of Done remainderBuf stateVal -> do (v2, nextHandler) <- (handleNext handler) v1 (reduce stateVal)@@ -177,7 +168,20 @@ Fail _ _ err -> do (v2,_) <- (handleNext handler) v1 (InternalError err) finalizeFailure v2- Partial f -> go out f "" v1 handler+ Partial f -> do+ -- NOTE: on End-Of-File we attempt to feed an empty byte to+ -- conclude the parse.+ -- Thus the real "final marked" is when the Handle is at EOF and+ -- the input chunk is empty.+ -- A more explicit final-result marker could benefit the+ -- implementation of ResultHandler.+ eof <- hIsEOF out+ case (eof, ByteString.null buf) of+ (True, True) -> inputFinished v1+ (True, False) -> go out f "" v1 handler+ _ -> do+ dat <- ByteString.hGetLine out+ go out f dat v1 handler inputFinished = pure userFinished = pure