Skip to content

Commit e31fa2d

Browse files
committed
Add Show (AsType a) instance
1 parent a2df13b commit e31fa2d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cardano-api/src/Cardano/Api/HasTypeProxy.hs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ where
1515
import Data.ByteString qualified as BS
1616
import Data.ByteString.Lazy qualified as BSL
1717
import Data.Kind (Constraint, Type)
18-
import Data.Proxy (Proxy (..))
19-
import Data.Typeable (Typeable)
18+
import Data.Typeable
2019
import Data.Word (Word16, Word8)
2120
import Numeric.Natural (Natural)
2221

@@ -29,6 +28,13 @@ class Typeable t => HasTypeProxy t where
2928

3029
proxyToAsType :: Proxy t -> AsType t
3130

31+
-- | Generalised show instance for all singletons of 'AsType' displaying the type.
32+
instance Typeable t => Show (AsType t) where
33+
show = show . typeRep . proxy
34+
where
35+
proxy :: AsType t -> Proxy t
36+
proxy _ = Proxy
37+
3238
instance HasTypeProxy Word8 where
3339
data AsType Word8 = AsWord8
3440
proxyToAsType _ = AsWord8

0 commit comments

Comments
 (0)