on master help sign in
HLint suggestions
30a991dMatej Kollar
Text/Libyaml.hs+5−8
@@ -4,8 +4,6 @@
4{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleContexts #-}
5{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
6{-# LANGUAGE MultiParamTypeClasses #-}
6{-# LANGUAGE MultiParamTypeClasses #-}
7−{-# LANGUAGE PackageImports #-}
8−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
9{-# LANGUAGE RankNTypes #-}
7{-# LANGUAGE RankNTypes #-}
10{-# LANGUAGE CPP #-}
8{-# LANGUAGE CPP #-}
11{-# LANGUAGE TypeFamilies #-}
9{-# LANGUAGE TypeFamilies #-}
@@ -48,13 +46,12 @@ import Data.Data
48
46
49import Control.Monad.IO.Class
47import Control.Monad.IO.Class
50
48
51−import Control.Exception (throwIO, Exception, finally)
49+import Control.Exception (mask_, throwIO, Exception, finally)
52#if !MIN_VERSION_base(4,8,0)
50#if !MIN_VERSION_base(4,8,0)
53import Control.Applicative
51import Control.Applicative
54#endif
52#endif
55import Control.Monad.Trans.Resource
53import Control.Monad.Trans.Resource
56import Data.Conduit hiding (Source, Sink, Conduit)
54import Data.Conduit hiding (Source, Sink, Conduit)
57−import Control.Exception (mask_)
58
55
59data Event =
56data Event =
60 EventStreamStart
57 EventStreamStart
@@ -267,20 +264,20 @@ getEvent er = do
267 yanchor <- c_get_scalar_anchor er
264 yanchor <- c_get_scalar_anchor er
268 anchor <- if yanchor == nullPtr
265 anchor <- if yanchor == nullPtr
269 then return Nothing
266 then return Nothing
270− else fmap Just $ peekCString yanchor
267+ else Just <$> peekCString yanchor
271 return $ Just $ EventScalar bs (bsToTag tagbs) style anchor
268 return $ Just $ EventScalar bs (bsToTag tagbs) style anchor
272 YamlSequenceStartEvent -> do
269 YamlSequenceStartEvent -> do
273 yanchor <- c_get_sequence_start_anchor er
270 yanchor <- c_get_sequence_start_anchor er
274 anchor <- if yanchor == nullPtr
271 anchor <- if yanchor == nullPtr
275 then return Nothing
272 then return Nothing
276− else fmap Just $ peekCString yanchor
273+ else Just <$> peekCString yanchor
277 return $ Just $ EventSequenceStart anchor
274 return $ Just $ EventSequenceStart anchor
278 YamlSequenceEndEvent -> return $ Just EventSequenceEnd
275 YamlSequenceEndEvent -> return $ Just EventSequenceEnd
279 YamlMappingStartEvent -> do
276 YamlMappingStartEvent -> do
280 yanchor <- c_get_mapping_start_anchor er
277 yanchor <- c_get_mapping_start_anchor er
281 anchor <- if yanchor == nullPtr
278 anchor <- if yanchor == nullPtr
282 then return Nothing
279 then return Nothing
283− else fmap Just $ peekCString yanchor
280+ else Just <$> peekCString yanchor
284 return $ Just $ EventMappingStart anchor
281 return $ Just $ EventMappingStart anchor
285 YamlMappingEndEvent -> return $ Just EventMappingEnd
282 YamlMappingEndEvent -> return $ Just EventMappingEnd
286
283
@@ -605,7 +602,7 @@ encodeFile filePath =
605 file <- withCString filePath $
602 file <- withCString filePath $
606 \filePath' -> withCString "w" $
603 \filePath' -> withCString "w" $
607 \w' -> c_fopen filePath' w'
604 \w' -> c_fopen filePath' w'
608− if (file == nullPtr)
605+ if file == nullPtr
609 then throwIO $ YamlException $ "could not open file for write: " ++ filePath
606 then throwIO $ YamlException $ "could not open file for write: " ++ filePath
610 else return file
607 else return file
611
608