-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #379 from input-output-hk/newhoggy/json-instances-…
…for-TxValidationError `ToJSON` instance for `TxValidationError`
- Loading branch information
Showing
6 changed files
with
219 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Cardano.Api.Via.ShowOf | ||
( ShowOf(..) | ||
) where | ||
|
||
import Data.Aeson | ||
import qualified Data.Aeson.Key as Key | ||
import Data.Aeson.Types | ||
import qualified Data.Text as Text | ||
import Prettyprinter | ||
|
||
newtype ShowOf a = ShowOf a | ||
|
||
instance Show a => Show (ShowOf a) where | ||
show (ShowOf a) = show a | ||
|
||
instance Show a => Pretty (ShowOf a) where | ||
pretty = viaShow | ||
|
||
instance Show a => ToJSON (ShowOf a) where | ||
toJSON (ShowOf a) = String (Text.pack (show a)) | ||
|
||
instance Show a => ToJSONKey (ShowOf a) where | ||
toJSONKey = toJSONKeyKey (Key.fromString . show) |