on master help sign in
Add missing MonadFail constraints
dff0490Michael Schröder
src/Graphics/Vty/Output.hs+4−3
@@ -38,6 +38,7 @@ import Graphics.Vty.Output.TerminfoBased as TerminfoBased
38
38
39import Blaze.ByteString.Builder (writeToByteString)
39import Blaze.ByteString.Builder (writeToByteString)
40
40
41+import Control.Monad.Fail (MonadFail)
41import Control.Monad.Trans
42import Control.Monad.Trans
42
43
43import Data.List (isPrefixOf)
44import Data.List (isPrefixOf)
@@ -84,7 +85,7 @@ outputForConfig config = (<> config) <$> standardIOConfig >>= outputForConfig
84-- Currently, the only way to set the cursor position to a given
85-- Currently, the only way to set the cursor position to a given
85-- character coordinate is to specify the coordinate in the Picture
86-- character coordinate is to specify the coordinate in the Picture
86-- instance provided to 'outputPicture' or 'refresh'.
87-- instance provided to 'outputPicture' or 'refresh'.
87−setCursorPos :: MonadIO m => Output -> Int -> Int -> m ()
88+setCursorPos :: (MonadIO m, MonadFail m) => Output -> Int -> Int -> m ()
88setCursorPos t x y = do
89setCursorPos t x y = do
89 bounds <- displayBounds t
90 bounds <- displayBounds t
90 when (x >= 0 && x < regionWidth bounds && y >= 0 && y < regionHeight bounds) $ do
91 when (x >= 0 && x < regionWidth bounds && y >= 0 && y < regionHeight bounds) $ do
@@ -92,14 +93,14 @@ setCursorPos t x y = do
92 liftIO $ outputByteBuffer t $ writeToByteString $ writeMoveCursor dc x y
93 liftIO $ outputByteBuffer t $ writeToByteString $ writeMoveCursor dc x y
93
94
94-- | Hides the cursor.
95-- | Hides the cursor.
95−hideCursor :: MonadIO m => Output -> m ()
96+hideCursor :: (MonadIO m, MonadFail m) => Output -> m ()
96hideCursor t = do
97hideCursor t = do
97 bounds <- displayBounds t
98 bounds <- displayBounds t
98 dc <- displayContext t bounds
99 dc <- displayContext t bounds
99 liftIO $ outputByteBuffer t $ writeToByteString $ writeHideCursor dc
100 liftIO $ outputByteBuffer t $ writeToByteString $ writeHideCursor dc
100
101
101-- | Shows the cursor.
102-- | Shows the cursor.
102−showCursor :: MonadIO m => Output -> m ()
103+showCursor :: (MonadIO m, MonadFail m) => Output -> m ()
103showCursor t = do
104showCursor t = do
104 bounds <- displayBounds t
105 bounds <- displayBounds t
105 dc <- displayContext t bounds
106 dc <- displayContext t bounds
src/Graphics/Vty/Output/Interface.hs+2−1
@@ -29,6 +29,7 @@ import Graphics.Vty.DisplayAttributes
29import Blaze.ByteString.Builder (Write, writeToByteString)
29import Blaze.ByteString.Builder (Write, writeToByteString)
30import Blaze.ByteString.Builder.ByteString (writeByteString)
30import Blaze.ByteString.Builder.ByteString (writeByteString)
31
31
32+import Control.Monad.Fail (MonadFail)
32import Control.Monad.Trans
33import Control.Monad.Trans
33
34
34import qualified Data.ByteString as BS
35import qualified Data.ByteString as BS
@@ -76,7 +77,7 @@ data Output = Output
76 -- previous state then set the display state to the initial state.
77 -- previous state then set the display state to the initial state.
77 , releaseDisplay :: forall m. MonadIO m => m ()
78 , releaseDisplay :: forall m. MonadIO m => m ()
78 -- | Returns the current display bounds.
79 -- | Returns the current display bounds.
79− , displayBounds :: forall m. MonadIO m => m DisplayRegion
80+ , displayBounds :: forall m. (MonadIO m, MonadFail m) => m DisplayRegion
80 -- | Output the bytestring to the terminal device.
81 -- | Output the bytestring to the terminal device.
81 , outputByteBuffer :: BS.ByteString -> IO ()
82 , outputByteBuffer :: BS.ByteString -> IO ()
82 -- | Specifies the maximum number of colors supported by the
83 -- | Specifies the maximum number of colors supported by the
src/Graphics/Vty/Output/TerminfoBased.hs+5−4
@@ -25,6 +25,7 @@ import Graphics.Vty.Output.Interface
25
25
26import Blaze.ByteString.Builder (Write, writeToByteString, writeStorable)
26import Blaze.ByteString.Builder (Write, writeToByteString, writeStorable)
27
27
28+import Control.Monad.Fail (MonadFail)
28import Control.Monad.Trans
29import Control.Monad.Trans
29
30
30import Data.Bits ((.&.))
31import Data.Bits ((.&.))
@@ -203,25 +204,25 @@ reserveTerminal termName outFd = liftIO $ do
203 maybeSendCap s = when (isJust $ s terminfoCaps) . sendCap (fromJust . s)
204 maybeSendCap s = when (isJust $ s terminfoCaps) . sendCap (fromJust . s)
204 return t
205 return t
205
206
206−requireCap :: (Applicative m, MonadIO m) => Terminfo.Terminal -> String -> m CapExpression
207+requireCap :: (Applicative m, MonadIO m, MonadFail m) => Terminfo.Terminal -> String -> m CapExpression
207requireCap ti capName
208requireCap ti capName
208 = case Terminfo.getCapability ti (Terminfo.tiGetStr capName) of
209 = case Terminfo.getCapability ti (Terminfo.tiGetStr capName) of
209 Nothing -> fail $ "Terminal does not define required capability \"" ++ capName ++ "\""
210 Nothing -> fail $ "Terminal does not define required capability \"" ++ capName ++ "\""
210 Just capStr -> parseCap capStr
211 Just capStr -> parseCap capStr
211
212
212−probeCap :: (Applicative m, MonadIO m) => Terminfo.Terminal -> String -> m (Maybe CapExpression)
213+probeCap :: (Applicative m, MonadIO m, MonadFail m) => Terminfo.Terminal -> String -> m (Maybe CapExpression)
213probeCap ti capName
214probeCap ti capName
214 = case Terminfo.getCapability ti (Terminfo.tiGetStr capName) of
215 = case Terminfo.getCapability ti (Terminfo.tiGetStr capName) of
215 Nothing -> return Nothing
216 Nothing -> return Nothing
216 Just capStr -> Just <$> parseCap capStr
217 Just capStr -> Just <$> parseCap capStr
217
218
218−parseCap :: (Applicative m, MonadIO m) => String -> m CapExpression
219+parseCap :: (Applicative m, MonadIO m, MonadFail m) => String -> m CapExpression
219parseCap capStr = do
220parseCap capStr = do
220 case parseCapExpression capStr of
221 case parseCapExpression capStr of
221 Left e -> fail $ show e
222 Left e -> fail $ show e
222 Right cap -> return cap
223 Right cap -> return cap
223
224
224−currentDisplayAttrCaps :: ( Applicative m, MonadIO m )
225+currentDisplayAttrCaps :: ( Applicative m, MonadIO m, MonadFail m )
225 => Terminfo.Terminal
226 => Terminfo.Terminal
226 -> m DisplayAttrCaps
227 -> m DisplayAttrCaps
227currentDisplayAttrCaps ti
228currentDisplayAttrCaps ti
vty.cabal+3−2
@@ -30,7 +30,7 @@ extra-doc-files: README.md,
30 AUTHORS,
30 AUTHORS,
31 CHANGELOG.md,
31 CHANGELOG.md,
32 LICENSE
32 LICENSE
33−tested-with: GHC==7.10.3, GHC==8.0.2, GHC==8.2.2, GHC==8.4.3
33+tested-with: GHC==7.10.3, GHC==8.0.2, GHC==8.2.2, GHC==8.4.3, GHC==8.6.5
34
34
35source-repository head
35source-repository head
36 type: git
36 type: git
@@ -62,7 +62,8 @@ library
62 vector >= 0.7
62 vector >= 0.7
63
63
64 if !impl(ghc >= 8.0)
64 if !impl(ghc >= 8.0)
65− build-depends: semigroups >= 0.16
65+ build-depends: semigroups >= 0.16,
66+ fail
66
67
67 exposed-modules: Graphics.Vty
68 exposed-modules: Graphics.Vty
68 Graphics.Vty.Attributes
69 Graphics.Vty.Attributes