Merge pull request #8 from BeFunctional/edsko/show-json

Show instance for JSON
This commit is contained in:
Edsko de Vries 2023-03-23 17:33:35 +00:00 committed by GitHub
commit 0bdbb0f1cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,11 +19,12 @@ import Codec.Borsh
import Foreign.Rust.Failure
import GHC.Stack
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Encoding as Aeson (unsafeToEncoding)
import qualified Data.Aeson.Types as Aeson (parseFail)
import qualified Data.Binary.Builder as Binary
import qualified Data.ByteString.Lazy as Lazy (ByteString)
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Encoding as Aeson (unsafeToEncoding)
import qualified Data.Aeson.Types as Aeson (parseFail)
import qualified Data.Binary.Builder as Binary
import qualified Data.ByteString.Lazy as Lazy (ByteString)
import qualified Data.ByteString.Lazy.Char8 as Lazy.Char8
{-------------------------------------------------------------------------------
Serialisation
@ -34,6 +35,9 @@ newtype JSON = JSON Lazy.ByteString
deriving stock (Eq)
deriving newtype (BorshSize, ToBorsh, FromBorsh)
instance Show JSON where
show (JSON bs) = Lazy.Char8.unpack bs
-- | Types with a Rust-side JSON renderer
class ToJSON a where
toJSON :: a -> JSON