module Network.IPFS.Bytes.Types (Bytes(..)) where

import           Network.IPFS.Prelude

newtype Bytes = Bytes { Bytes -> Natural
unBytes :: Natural }
  deriving newtype ( Bytes -> Bytes -> Bool
(Bytes -> Bytes -> Bool) -> (Bytes -> Bytes -> Bool) -> Eq Bytes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Bytes -> Bytes -> Bool
$c/= :: Bytes -> Bytes -> Bool
== :: Bytes -> Bytes -> Bool
$c== :: Bytes -> Bytes -> Bool
Eq
                   , Int -> Bytes -> ShowS
[Bytes] -> ShowS
Bytes -> String
(Int -> Bytes -> ShowS)
-> (Bytes -> String) -> ([Bytes] -> ShowS) -> Show Bytes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Bytes] -> ShowS
$cshowList :: [Bytes] -> ShowS
show :: Bytes -> String
$cshow :: Bytes -> String
showsPrec :: Int -> Bytes -> ShowS
$cshowsPrec :: Int -> Bytes -> ShowS
Show
                   )

instance FromJSON Bytes where
  parseJSON :: Value -> Parser Bytes
parseJSON Value
val = do
    Natural
nat <- Value -> Parser Natural
forall a. FromJSON a => Value -> Parser a
parseJSON Value
val
    Bytes -> Parser Bytes
forall (m :: * -> *) a. Monad m => a -> m a
return (Bytes -> Parser Bytes) -> Bytes -> Parser Bytes
forall a b. (a -> b) -> a -> b
<| Natural -> Bytes
Bytes Natural
nat