on master help sign in
implement hlint suggestions
2d088d0AgentM
src/lib/ProjectM36/Tupleable.hs+1−1
@@ -178,7 +178,7 @@ class Tupleable a where
178 toAttributes = genericToAttributes defaultTupleableOptions
178 toAttributes = genericToAttributes defaultTupleableOptions
179
179
180-- | Options that influence deriving behavior.
180-- | Options that influence deriving behavior.
181−data TupleableOptions = TupleableOptions {
181+newtype TupleableOptions = TupleableOptions {
182 -- | A function that translates record field names into attribute names.
182 -- | A function that translates record field names into attribute names.
183 fieldModifier :: T.Text -> T.Text
183 fieldModifier :: T.Text -> T.Text
184 }
184 }
src/lib/ProjectM36/Tupleable/Deriving.hs+4−3
@@ -52,7 +52,7 @@ module ProjectM36.Tupleable.Deriving
52 , Generic
52 , Generic
53 , module ProjectM36.Tupleable
53 , module ProjectM36.Tupleable
54 ) where
54 ) where
55−
55+import Data.Maybe (fromMaybe)
56import Data.Proxy
56import Data.Proxy
57import qualified Data.Text as T
57import qualified Data.Text as T
58import Data.Text.Manipulate
58import Data.Text.Manipulate
@@ -60,6 +60,7 @@ import GHC.TypeLits
60import GHC.Generics (Generic, Rep)
60import GHC.Generics (Generic, Rep)
61import ProjectM36.Tupleable
61import ProjectM36.Tupleable
62
62
63+
63-- | A newtype wrapper to allow for easier deriving of 'Tupleable' instances
64-- | A newtype wrapper to allow for easier deriving of 'Tupleable' instances
64-- with customization.
65-- with customization.
65--
66--
@@ -128,7 +129,7 @@ instance KnownSymbol prefix => ModifyText (AddPrefix prefix) where
128data DropPrefix (prefix :: Symbol)
129data DropPrefix (prefix :: Symbol)
129
130
130instance KnownSymbol prefix => ModifyText (DropPrefix prefix) where
131instance KnownSymbol prefix => ModifyText (DropPrefix prefix) where
131− modifyText _ oldText = maybe oldText id (T.stripPrefix prefixText oldText)
132+ modifyText _ oldText = fromMaybe oldText (T.stripPrefix prefixText oldText)
132 where
133 where
133 prefixText = T.pack (symbolVal (Proxy :: Proxy prefix))
134 prefixText = T.pack (symbolVal (Proxy :: Proxy prefix))
134
135
@@ -144,7 +145,7 @@ instance KnownSymbol suffix => ModifyText (AddSuffix suffix) where
144data DropSuffix (suffix :: Symbol)
145data DropSuffix (suffix :: Symbol)
145
146
146instance KnownSymbol suffix => ModifyText (DropSuffix suffix) where
147instance KnownSymbol suffix => ModifyText (DropSuffix suffix) where
147− modifyText _ oldText = maybe oldText id (T.stripSuffix suffixText oldText)
148+ modifyText _ oldText = fromMaybe oldText (T.stripSuffix suffixText oldText)
148 where
149 where
149 suffixText = T.pack (symbolVal (Proxy :: Proxy suffix))
150 suffixText = T.pack (symbolVal (Proxy :: Proxy suffix))
150
151