ihaskell: Remove partial-fields

GHC 8.4 and later have the `-Wpartial-fields` warning flag, so add it and
fix the warnings.
This commit is contained in:
Erik de Castro Lopo 2018-09-03 20:14:15 +10:00
parent 8c37c42276
commit ba9dadecae
4 changed files with 39 additions and 21 deletions

View File

@ -50,6 +50,10 @@ library
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -Wall
if impl (ghc >= 8.4)
ghc-options: -Wpartial-fields
build-depends:
aeson >=1.0,
base >=4.9,
@ -123,6 +127,9 @@ executable ihaskell
Paths_ihaskell
ghc-options: -threaded -rtsopts -Wall
if impl (ghc >= 8.4)
ghc-options: -Wpartial-fields
-- Other library packages from which modules are imported.
default-language: Haskell2010
build-depends:
@ -143,6 +150,10 @@ executable ihaskell
Test-Suite hspec
Type: exitcode-stdio-1.0
Ghc-Options: -threaded -Wall
if impl (ghc >= 8.4)
ghc-options: -Wpartial-fields
Main-Is: Hspec.hs
hs-source-dirs: src/tests
other-modules:

View File

@ -1,5 +1,7 @@
{-# language NoImplicitPrelude, DoAndIfThenElse, OverloadedStrings, ExtendedDefaultRules #-}
module IHaskell.Publish (publishResult) where
module IHaskell.Publish
( publishResult
) where
import IHaskellPrelude
@ -30,7 +32,7 @@ publishResult send replyHeader displayed updateNeeded poutput upager result = do
case result of
IntermediateResult{} -> False
FinalResult{} -> True
outs = outputs result
outs = evaluationOutputs result
-- If necessary, clear all previous output and redraw.
clear <- readMVar updateNeeded
@ -49,11 +51,13 @@ publishResult send replyHeader displayed updateNeeded poutput upager result = do
modifyMVar_ displayed (return . (outs :))
-- If this has some pager output, store it for later.
let pager = pagerOut result
unless (null pager) $
if upager
then modifyMVar_ poutput (return . (++ pager))
else sendOutput $ Display pager
case result of
IntermediateResult _ -> pure ()
FinalResult _ pager _ ->
unless (null pager) $
if upager
then modifyMVar_ poutput (return . (++ pager))
else sendOutput $ Display pager
where
clearOutput = do

View File

@ -19,6 +19,7 @@ module IHaskell.Types (
MimeType(..),
DisplayData(..),
EvaluationResult(..),
evaluationOutputs,
ExecuteReplyStatus(..),
KernelState(..),
LintStatus(..),
@ -248,21 +249,23 @@ instance ToJSON WidgetMethod where
toJSON (CustomContent v) = object ["method" .= ("custom" :: Text), "content" .= v]
-- | Output of evaluation.
data EvaluationResult =
-- | An intermediate result which communicates what has been printed thus
-- far.
IntermediateResult
{ outputs :: Display -- ^ Display outputs.
}
|
FinalResult
{ outputs :: Display -- ^ Display outputs.
, pagerOut :: [DisplayData] -- ^ Mimebundles to display in the IPython
-- pager.
, commMsgs :: [WidgetMsg] -- ^ Comm operations
}
data EvaluationResult
-- | An intermediate result which communicates what has been printed thus far.
= IntermediateResult
!Display -- ^ Display outputs.
| FinalResult
!Display -- ^ Display outputs.
![DisplayData] -- ^ Mimebundles to display in the IPython pager.
![WidgetMsg] -- ^ Comm operations
deriving Show
evaluationOutputs :: EvaluationResult -> Display
evaluationOutputs er =
case er of
IntermediateResult outputs -> outputs
FinalResult outputs _ _ -> outputs
-- | Duplicate a message header, giving it a new UUID and message type.
dupHeader :: MessageHeader -> MessageType -> IO MessageHeader
dupHeader hdr messageType = do

View File

@ -26,7 +26,7 @@ extra-deps:
ghc-options:
# Eventually we want "$locals": -Wall -Wpartial-fields -Werror
ghc-parser: -Wall -Wpartial-fields -Werror
ihaskell: -Wall -Werror
ihaskell: -Wall -Wpartial-fields -Werror
ihaskell-widgets: -Wall -Wpartial-fields -Werror
nix: