Skip to content

Commit

Permalink
Fix hlint issues in Types.hs
Browse files Browse the repository at this point in the history
  • Loading branch information
colonelpanic8 committed Mar 16, 2018
1 parent 18d0926 commit 1e5c3a4
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions lib/DBus/Internal/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ signature = check where
--
-- Throws an exception if the given types are not a valid signature.
signature_ :: [Type] -> Signature
signature_ ts = case signature ts of
Just sig -> sig
Nothing -> error ("invalid signature: " ++ show ts)
signature_ ts = fromMaybe ("invalid signature: " ++ show ts) $ signature ts

-- | Parse a signature string into a valid signature.
--
Expand Down Expand Up @@ -595,10 +593,10 @@ instance (Ord k, IsAtom k, IsValue v) => IsValue (Map k v) where
fromValue _ = Nothing

bimap :: Ord k' => (k -> v -> (k', v')) -> Map k v -> Map k' v'
bimap f = Data.Map.fromList . map (\(k, v) -> f k v) . Data.Map.toList
bimap f = Data.Map.fromList . map uncurry f . Data.Map.toList

bimapM :: (Monad m, Ord k') => (k -> v -> m (k', v')) -> Map k v -> m (Map k' v')
bimapM f = liftM Data.Map.fromList . mapM (\(k, v) -> f k v) . Data.Map.toList
bimapM f = fmap Data.Map.fromList . mapM uncurry . Data.Map.toList

mapItemType :: (IsValue k, IsValue v) => Map k v -> (Type, Type)
mapItemType m = (typeOf k, typeOf v) where
Expand Down Expand Up @@ -687,7 +685,7 @@ parserObjectPath = root <|> object where

element = Parsec.skipMany1 (oneOf chars)

slash = Parsec.char '/' >> return ()
slash = void $ Parsec.char '/'
chars = concat [ ['a'..'z']
, ['A'..'Z']
, ['0'..'9']
Expand Down Expand Up @@ -841,14 +839,14 @@ parserBusName = name >> Parsec.eof where

wellKnown = elements alpha

elements :: [Char] -> Parsec.Parser ()
elements :: String -> Parsec.Parser ()
elements start = do
element start
Parsec.skipMany1 $ do
_ <- Parsec.char '.'
element start

element :: [Char] -> Parsec.Parser ()
element :: String -> Parsec.Parser ()
element start = do
_ <- oneOf start
Parsec.skipMany (oneOf alphanum)
Expand Down Expand Up @@ -1361,9 +1359,8 @@ skipSepBy1 p sep = do
Parsec.skipMany (sep >> p)

forceParse :: String -> (String -> Maybe a) -> String -> a
forceParse label parse str = case parse str of
Just x -> x
Nothing -> error ("Invalid " ++ label ++ ": " ++ show str)
forceParse label parse str =
fromMaybe error ("Invalid " ++ label ++ ": " ++ show str) parse str

maybeParseString :: Parsec.Parser a -> String -> Maybe a
maybeParseString parser s = case Parsec.parse parser "" s of
Expand Down

0 comments on commit 1e5c3a4

Please sign in to comment.