on master help sign in
implement hlint suggestions
commit2d088d0d25498f8627ef64545510e22da009e522 authorAgentM <agentm@themactionfaction.com> dateSat 4 Jul 2020, 19:47 (6 years ago) parent6de3939
2 files changed+5−4
src/lib/ProjectM36/Tupleable.hs+1−1 src/lib/ProjectM36/Tupleable/Deriving.hs+4−3
src/lib/ProjectM36/Tupleable.hs+1−1
@@ -178,7 +178,7 @@ class Tupleable a where
178178 toAttributes = genericToAttributes defaultTupleableOptions
179179
180180-- | Options that influence deriving behavior.
181−data TupleableOptions = TupleableOptions {
181+newtype TupleableOptions = TupleableOptions {
182182 -- | A function that translates record field names into attribute names.
183183 fieldModifier :: T.Text -> T.Text
184184 }
src/lib/ProjectM36/Tupleable/Deriving.hs+4−3
@@ -52,7 +52,7 @@ module ProjectM36.Tupleable.Deriving
5252 , Generic
5353 , module ProjectM36.Tupleable
5454 ) where
55−
55+import Data.Maybe (fromMaybe)
5656import Data.Proxy
5757import qualified Data.Text as T
5858import Data.Text.Manipulate
@@ -60,6 +60,7 @@ import GHC.TypeLits
6060import GHC.Generics (Generic, Rep)
6161import ProjectM36.Tupleable
6262
63+
6364-- | A newtype wrapper to allow for easier deriving of 'Tupleable' instances
6465-- with customization.
6566--
@@ -128,7 +129,7 @@ instance KnownSymbol prefix => ModifyText (AddPrefix prefix) where
128129data DropPrefix (prefix :: Symbol)
129130
130131instance 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)
132133 where
133134 prefixText = T.pack (symbolVal (Proxy :: Proxy prefix))
134135
@@ -144,7 +145,7 @@ instance KnownSymbol suffix => ModifyText (AddSuffix suffix) where
144145data DropSuffix (suffix :: Symbol)
145146
146147instance 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)
148149 where
149150 suffixText = T.pack (symbolVal (Proxy :: Proxy suffix))
150151