Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cardano-base/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 0.1.4.0

* Add `Cardano.Base.Typeable` module with type `TypeName a` and its `IsString` and `Show` instances.
* Add a workaround for QuickCheck >= 2.18 replacing `withMaxSuccess`
with `withNumTests` and deprecating the former.

Expand Down
1 change: 1 addition & 0 deletions cardano-base/cardano-base.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ library
Cardano.Base.FeatureFlags
Cardano.Base.IP
Cardano.Base.Proxy
Cardano.Base.Typeable

build-depends:
aeson,
Expand Down
23 changes: 23 additions & 0 deletions cardano-base/src/Cardano/Base/Typeable.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}

-- | Wrapper for Data.Typeable, plus convenience functions
Comment thread
lehins marked this conversation as resolved.
module Cardano.Base.Typeable (
module X,
TypeName (..),
) where

import Data.String (IsString (fromString))
import Data.Typeable as X

data TypeName a where
Comment thread
aniketd marked this conversation as resolved.
TypeNameString :: String -> TypeName a
TypeName :: Typeable a => TypeName a

instance IsString (TypeName a) where
fromString = TypeNameString

instance Show (TypeName a) where
show = \case
TypeNameString name -> name
t@(TypeName {}) -> show (typeRep t)
Loading