on develop help sign in
Some cleanup with the help of HLint suggestions
commitb966e3662be165fdcfc167a6a52a0dfeaef722eb authorKoray Al <admin@koray.al> dateWed 13 Feb 2019, 23:17 (8 years ago) parent944435c
11 files changed+32−59
gen/src/Gen/AST/Flatten.hs+1−5 gen/src/Gen/AST/Render.hs+3−7 gen/src/Gen/AST/Solve.hs+2−7 gen/src/Gen/Formatting.hs−2 gen/src/Gen/Syntax.hs+6−7 gen/src/Gen/Text.hs−1 gen/src/Gen/Tree.hs−1 gen/src/Gen/Types/Data.hs+8−15 gen/src/Gen/Types/Help.hs+8−8 gen/src/Gen/Types/Id.hs+1−3 gen/src/Gen/Types/Schema.hs+3−3
gen/src/Gen/AST/Flatten.hs+1−5
@@ -1,14 +1,10 @@
11{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE DeriveGeneric #-}
32{-# LANGUAGE FlexibleContexts #-}
43{-# LANGUAGE FlexibleInstances #-}
5−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
6−{-# LANGUAGE KindSignatures #-}
74{-# LANGUAGE LambdaCase #-}
85{-# LANGUAGE OverloadedStrings #-}
96{-# LANGUAGE RankNTypes #-}
107{-# LANGUAGE RecordWildCards #-}
11−{-# LANGUAGE TemplateHaskell #-}
128{-# LANGUAGE TupleSections #-}
139
1410-- Module : Gen.AST.Flatten
@@ -136,7 +132,7 @@ resource :: Map Local (Param Global)
136132 -> Resource (Fix Schema)
137133 -> AST (Resource Global)
138134resource qs suf g r@Resource {..} = do
139− rs <- Map.traverseWithKey (\l -> resource qs suf (reference g l)) _rResources
135+ rs <- Map.traverseWithKey (resource qs suf . reference g) _rResources
140136 ms <- traverse (method qs suf) _rMethods
141137 pure $! r
142138 { _rResources = rs
gen/src/Gen/AST/Render.hs+3−7
@@ -1,14 +1,10 @@
11{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE DeriveGeneric #-}
32{-# LANGUAGE FlexibleContexts #-}
43{-# LANGUAGE FlexibleInstances #-}
5−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
6−{-# LANGUAGE KindSignatures #-}
74{-# LANGUAGE LambdaCase #-}
85{-# LANGUAGE OverloadedStrings #-}
96{-# LANGUAGE RankNTypes #-}
107{-# LANGUAGE RecordWildCards #-}
11−{-# LANGUAGE TemplateHaskell #-}
128{-# LANGUAGE ViewPatterns #-}
139
1410-- Module : Gen.AST.Render
@@ -25,9 +21,9 @@ module Gen.AST.Render
2521import Control.Applicative
2622import Control.Error
2723import Control.Lens hiding (enum, lens)
28−import qualified Data.ByteString.Char8 as C8
29−import qualified Data.ByteString.Lazy.Char8 as LBS
24+import qualified Data.ByteString.Char8 as C8
3025import qualified Data.ByteString.Lazy.Builder as LBB
26+import qualified Data.ByteString.Lazy.Char8 as LBS
3127import Data.Char (isSpace)
3228import qualified Data.HashMap.Strict as Map
3329import Data.Maybe
@@ -136,7 +132,7 @@ renderMethod s root suf m@Method {..} = do
136132 x@Solved {..} <- getSolved typ
137133 d' <- renderSchema x
138134 d <- case d' of
139− Nothing -> error "failed to render the schema"
135+ Nothing -> error "failed to render the schema"
140136 Just d'' -> pure d''
141137
142138 i <- pp Print $ requestDecl _unique _prefix alias url (props _schema) m
gen/src/Gen/AST/Solve.hs+2−7
@@ -1,14 +1,9 @@
11{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE DeriveGeneric #-}
32{-# LANGUAGE FlexibleContexts #-}
43{-# LANGUAGE FlexibleInstances #-}
5−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
6−{-# LANGUAGE KindSignatures #-}
74{-# LANGUAGE LambdaCase #-}
85{-# LANGUAGE OverloadedStrings #-}
96{-# LANGUAGE RankNTypes #-}
10−{-# LANGUAGE RecordWildCards #-}
11−{-# LANGUAGE TemplateHaskell #-}
127{-# LANGUAGE ViewPatterns #-}
138
149-- Module : Gen.AST.Solve
@@ -94,7 +89,7 @@ getType g = loc "getType" g $ memo typed g go
9489 --- FIXME: add natural/numeric manipulations
9590 SLit _ l -> res (TLit l)
9691 SEnm {} -> res (TType g)
97− SArr _ (Arr e) -> (TList <$> (getType e)) >>= pure . may
92+ SArr _ (Arr e) -> may <$> (TList <$> getType e)
9893 SObj {} -> res (TType g)
9994 SRef _ r
10095 | ref r /= g -> req <$> getType (ref r)
@@ -195,7 +190,7 @@ overlap :: (Eq a, Hashable a) => Set a -> Set a -> Bool
195190overlap xs ys = not . Set.null $ Set.intersection xs ys
196191
197192acronymPrefixes :: Global -> [CI Text]
198−acronymPrefixes (global -> renameSpecial -> g) =
193+acronymPrefixes (global -> (renameSpecial -> g)) =
199194 filter (/= full) $ map CI.mk (xs ++ map suffix ys ++ zs)
200195 where
201196 -- Take the next char
gen/src/Gen/Formatting.hs−2
@@ -1,5 +1,3 @@
1−{-# LANGUAGE OverloadedStrings #-}
2−
31-- Module : Gen.Formatting
42-- Copyright : (c) 2015-2016 Brendan Hay
53-- License : Mozilla Public License, v. 2.0.
gen/src/Gen/Syntax.hs+6−7
@@ -1,6 +1,5 @@
11{-# LANGUAGE LambdaCase #-}
22{-# LANGUAGE OverloadedStrings #-}
3−{-# LANGUAGE TupleSections #-}
43{-# LANGUAGE ViewPatterns #-}
54
65-- Module : Gen.Syntax
@@ -335,7 +334,7 @@ googleRequestDecl n assoc extras pre api url m pat prec =
335334
336335 decls = BDecls ()
337336 [ patBind pat $
338− appFun (var "buildClient") $
337+ appFun (var "buildClient")
339338 [ ExpTypeSig () (var "Proxy") $
340339 TyApp () (TyCon () "Proxy") (TyCon () (UnQual () api))
341340 , var "mempty"
@@ -425,7 +424,7 @@ wildcardD f n enc x = \case
425424 prec = PRec () (UnQual () (dname' n)) [PFieldWildcard ()]
426425
427426defJS :: Local -> Exp () -> Exp ()
428−defJS n x = infixApp (infixApp (var "o") ".:?" (fstr n)) ".!=" x
427+defJS n = infixApp (infixApp (var "o") ".:?" (fstr n)) ".!="
429428
430429reqJS :: Local -> Exp ()
431430reqJS = infixApp (var "o") ".:" . fstr
@@ -449,7 +448,7 @@ seqE l (r:rs) = infixApp l "<$>" (infixE r "<*>" rs)
449448
450449objDecl :: Global -> Prefix -> [Derive] -> Map Local Solved -> Decl ()
451450objDecl n p ds rs =
452− DataDecl () arity Nothing (DHead () (dname n)) [conDecl (dname' n) p rs] [(der ds)]
451+ DataDecl () arity Nothing (DHead () (dname n)) [conDecl (dname' n) p rs] [der ds]
453452 where
454453 arity | Map.size rs == 1 = NewType ()
455454 | otherwise = DataType ()
@@ -620,9 +619,9 @@ mapping :: TType -> Exp () -> Exp ()
620619mapping t e = infixE e "." (go t)
621620 where
622621 go = \case
623− TMaybe x@(TList {}) -> var "_Default" : go x
624− TMaybe x -> nest (go x)
625− x -> maybeToList (iso x)
622+ TMaybe x@TList {} -> var "_Default" : go x
623+ TMaybe x -> nest (go x)
624+ x -> maybeToList (iso x)
626625
627626 nest [] = []
628627 nest (x:xs) = [app (var "mapping") (infixE x "." xs)]
gen/src/Gen/Text.hs−1
@@ -1,5 +1,4 @@
11{-# LANGUAGE OverloadedStrings #-}
2−{-# LANGUAGE TupleSections #-}
32
43-- Module : Gen.Text
54-- Copyright : (c) 2013-2015 Brendan Hay
gen/src/Gen/Tree.hs−1
@@ -5,7 +5,6 @@
55{-# LANGUAGE MultiParamTypeClasses #-}
66{-# LANGUAGE OverloadedStrings #-}
77{-# LANGUAGE RecordWildCards #-}
8−{-# LANGUAGE TupleSections #-}
98{-# LANGUAGE ViewPatterns #-}
109
1110-- Module : Gen.Tree
gen/src/Gen/Types/Data.hs+8−15
@@ -1,17 +1,10 @@
1−{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE DeriveFoldable #-}
3−{-# LANGUAGE DeriveFunctor #-}
4−{-# LANGUAGE DeriveGeneric #-}
5−{-# LANGUAGE DeriveTraversable #-}
6−{-# LANGUAGE ExtendedDefaultRules #-}
7−{-# LANGUAGE FlexibleContexts #-}
8−{-# LANGUAGE FlexibleInstances #-}
9−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
10−{-# LANGUAGE KindSignatures #-}
11−{-# LANGUAGE LambdaCase #-}
12−{-# LANGUAGE OverloadedStrings #-}
13−{-# LANGUAGE RecordWildCards #-}
14−{-# LANGUAGE TemplateHaskell #-}
1+{-# LANGUAGE DataKinds #-}
2+{-# LANGUAGE ExtendedDefaultRules #-}
3+{-# LANGUAGE FlexibleContexts #-}
4+{-# LANGUAGE FlexibleInstances #-}
5+{-# LANGUAGE LambdaCase #-}
6+{-# LANGUAGE OverloadedStrings #-}
7+{-# LANGUAGE RecordWildCards #-}
158
169{-# OPTIONS_GHC -fno-warn-type-defaults #-}
1710
@@ -42,7 +35,7 @@ default (Text)
4235
4336type Rendered = LText.Text
4437
45−data Syn a = Syn { syntax :: a }
38+newtype Syn a = Syn { syntax :: a }
4639
4740instance Pretty a => ToJSON (Syn a) where
4841 toJSON = toJSON . prettyPrint . syntax
gen/src/Gen/Types/Help.hs+8−8
@@ -15,16 +15,16 @@ module Gen.Types.Help
1515 , rawHelpText
1616 ) where
1717
18−import Data.Aeson
19−import Data.Char (isSpace)
20−import Data.String
21−import Data.Text (Text)
22−import qualified System.IO.Unsafe as Unsafe
18+import Data.Aeson
19+import Data.Char (isSpace)
20+import Data.String
21+import Data.Text (Text)
22+import qualified System.IO.Unsafe as Unsafe
2323
24−import Text.Pandoc as Pandoc
25−import Text.Pandoc.Pretty
24+import Text.Pandoc as Pandoc
25+import Text.Pandoc.Pretty
2626
27−import qualified Data.Text as Text
27+import qualified Data.Text as Text
2828
2929data Help
3030 = Help ![Help]
gen/src/Gen/Types/Id.hs+1−3
@@ -1,7 +1,6 @@
11{-# LANGUAGE DeriveGeneric #-}
22{-# LANGUAGE FlexibleInstances #-}
33{-# LANGUAGE GeneralizedNewtypeDeriving #-}
4−{-# LANGUAGE LambdaCase #-}
54{-# LANGUAGE OverloadedStrings #-}
65{-# LANGUAGE ScopedTypeVariables #-}
76{-# LANGUAGE TupleSections #-}
@@ -62,8 +61,7 @@ import qualified Data.CaseInsensitive as CI
6261import Data.Foldable (foldl')
6362import Data.Function (on)
6463import Data.Hashable
65−import Data.List (intersperse)
66−import Data.List (elemIndex, nub, sortOn)
64+import Data.List (elemIndex, intersperse, nub, sortOn)
6765import Data.String
6866import Data.Text (Text)
6967import qualified Data.Text as Text
gen/src/Gen/Types/Schema.hs+3−3
@@ -425,7 +425,7 @@ data Service a = Service
425425 , _sOwnerName :: Text
426426 , _sOwnerDomain :: Text
427427 , _sPackagePath :: Maybe Text
428− , _sDescription :: (Description a)
428+ , _sDescription :: Description a
429429 } deriving (Eq, Show)
430430
431431makeClassy ''Service
@@ -448,8 +448,8 @@ serviceName = Text.unpack . (<> "Service") . toCamel . _sCanonicalName
448448scopeName :: Service a -> Text -> String
449449scopeName s k = Text.unpack . lowerHead . lowerFirstAcronym $
450450 case breakParts k of
451− [] -> _sCanonicalName s <> "AllScope"
452− xs -> foldMap named xs <> "Scope"
451+ [] -> _sCanonicalName s <> "AllScope"
452+ xs -> foldMap named xs <> "Scope"
453453 where
454454 breakParts =
455455 concatMap (Text.split split)