Skip to content

Commit 0b77129

Browse files
authored
Merge pull request #16 from f-o-a-m/string-like-hex
add typeclass instance for parsing
2 parents 420889a + 7e11baf commit 0b77129

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"purescript-simple-json": "^4.0.0",
2525
"purescript-ordered-collections": "^1.0.0",
2626
"purescript-bytestrings": "^7.0.0",
27-
"purescript-argonaut": "^5.0.0"
27+
"purescript-argonaut": "^5.0.0",
28+
"purescript-parsing": "5.0.0"
2829
},
2930
"devDependencies": {
3031
"purescript-psci-support": "^4.0.0",

src/Network/Ethereum/Core/HexString.purs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import Network.Ethereum.Core.BigNumber (BigNumber, toString, hexadecimal)
4444
import Node.Encoding (Encoding(Hex, UTF8, ASCII))
4545
import Partial.Unsafe (unsafePartial)
4646
import Simple.JSON (class ReadForeign, class WriteForeign)
47+
import Text.Parsing.Parser.String (class StringLike)
4748

4849
--------------------------------------------------------------------------------
4950
-- * Signed Values
@@ -90,6 +91,8 @@ derive newtype instance hexStringOrd :: Ord HexString
9091
derive newtype instance semigpStringEq :: Semigroup HexString
9192
derive newtype instance monoidStringEq :: Monoid HexString
9293

94+
derive newtype instance stringLikeHexString :: StringLike HexString
95+
9396
_encode :: HexString -> String
9497
_encode = append "0x" <<< unHex
9598

@@ -156,6 +159,7 @@ dropHex n (HexString hx) = HexString $ S.drop n hx
156159
nullWord :: HexString
157160
nullWord = HexString "0000000000000000000000000000000000000000000000000000000000000000"
158161

162+
159163
--------------------------------------------------------------------------------
160164
-- | Utils
161165
--------------------------------------------------------------------------------

0 commit comments

Comments
 (0)