mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-11-13 09:17:21 +03:00
server: add tshow :: Show a => a -> Text, including hlint hint (#142)
GitOrigin-RevId: 627a55533831b51aa0d01f8a8d95e3d013744dc5
This commit is contained in:
parent
f5e56e8981
commit
5edca3a5c2
@ -110,6 +110,7 @@
|
||||
- warn: {lhs: "case x of {Nothing -> a; Just b -> return b}", rhs: "onNothing x a"}
|
||||
- warn: {lhs: "case x of {Just b -> return b; Nothing -> a}", rhs: "onNothing x a"}
|
||||
- warn: {lhs: "fromMaybe [] x", rhs: "maybeToList x"}
|
||||
- warn: {lhs: "Data.Text.pack (Prelude.show x)", rhs: "Hasura.Prelude.tshow x"}
|
||||
|
||||
- group:
|
||||
name: data-text-extended
|
||||
|
@ -16,6 +16,7 @@ module Hasura.Prelude
|
||||
, spanMaybeM
|
||||
, liftEitherM
|
||||
, hoistMaybe
|
||||
, tshow
|
||||
-- * Efficient coercions
|
||||
, coerce
|
||||
, findWithIndex
|
||||
@ -184,3 +185,6 @@ startTimer = do
|
||||
-- copied from http://hackage.haskell.org/package/errors-2.3.0/docs/src/Control.Error.Util.html#hoistMaybe
|
||||
hoistMaybe :: (Monad m) => Maybe b -> MaybeT m b
|
||||
hoistMaybe = MaybeT . return
|
||||
|
||||
tshow :: Show a => a -> Text
|
||||
tshow = T.pack . show
|
||||
|
@ -1,7 +1,7 @@
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
module Network.URI.Extended
|
||||
(module Network.URI
|
||||
( module Network.URI
|
||||
)
|
||||
where
|
||||
|
||||
@ -20,10 +20,10 @@ instance {-# INCOHERENT #-} FromJSON URI where
|
||||
parseJSON _ = fail "not a valid URI"
|
||||
|
||||
instance {-# INCOHERENT #-} ToJSON URI where
|
||||
toJSON = String . T.pack . show
|
||||
toJSON = String . tshow
|
||||
|
||||
instance {-# INCOHERENT #-} ToJSONKey URI where
|
||||
toJSONKey = toJSONKeyText (T.pack . show)
|
||||
toJSONKey = toJSONKeyText tshow
|
||||
|
||||
instance Hashable URI where
|
||||
hashWithSalt i = hashWithSalt i . (T.pack . show)
|
||||
hashWithSalt i = hashWithSalt i . tshow
|
||||
|
Loading…
Reference in New Issue
Block a user