summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriostat <>2017-03-20 15:26:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-03-20 15:26:00 (GMT)
commitf4dfb216f7abeb11d9ef619e95ea03d32925b959 (patch)
treea912ec3cc73fed33771251f28e8462b8ca2a9d52
parentaa9385d94889859e84f184068f93c1b897621388 (diff)
version 0.1.2.00.1.2.0
-rw-r--r--relapse.cabal2
-rw-r--r--src/Data/RLP/Types.hs104
2 files changed, 101 insertions, 5 deletions
diff --git a/relapse.cabal b/relapse.cabal
index 73a8d60..3c24447 100644
--- a/relapse.cabal
+++ b/relapse.cabal
@@ -1,5 +1,5 @@
name: relapse
-version: 0.1.1.1
+version: 0.1.2.0
synopsis: Sensible RLP encoding
description: An implementation of RLP as specified in the Ethereum Wiki, using Attoparsec
homepage: https://github.com/iostat/relapse#readme
diff --git a/src/Data/RLP/Types.hs b/src/Data/RLP/Types.hs
index 65caf07..4940a75 100644
--- a/src/Data/RLP/Types.hs
+++ b/src/Data/RLP/Types.hs
@@ -124,7 +124,7 @@ instance
<$> rlpDecode a
<*> rlpDecode b
<*> rlpDecode c
- x -> rlpDecodeFail "Triple" x
+ x -> rlpDecodeFail "Triple" x
instance
( RLPEncodable a
@@ -144,7 +144,7 @@ instance
<*> rlpDecode b
<*> rlpDecode c
<*> rlpDecode d
- x -> rlpDecodeFail "Quadruple" x
+ x -> rlpDecodeFail "Quadruple" x
instance
( RLPEncodable a
@@ -167,7 +167,7 @@ instance
<*> rlpDecode c
<*> rlpDecode d
<*> rlpDecode e
- x -> rlpDecodeFail "Quintuple" x
+ x -> rlpDecodeFail "Quintuple" x
instance
( RLPEncodable a
@@ -193,7 +193,103 @@ instance
<*> rlpDecode d
<*> rlpDecode e
<*> rlpDecode f
- x -> rlpDecodeFail "Sextuple" x
+ x -> rlpDecodeFail "Sextuple" x
+
+instance
+ ( RLPEncodable a
+ , RLPEncodable b
+ , RLPEncodable c
+ , RLPEncodable d
+ , RLPEncodable e
+ , RLPEncodable f
+ , RLPEncodable g
+ ) => RLPEncodable (a,b,c,d,e,f,g) where
+ rlpEncode (a,b,c,d,e,f,g) = Array
+ [ rlpEncode a
+ , rlpEncode b
+ , rlpEncode c
+ , rlpEncode d
+ , rlpEncode e
+ , rlpEncode f
+ , rlpEncode g
+ ]
+ rlpDecode = \case
+ Array [a,b,c,d,e,f,g] -> (,,,,,,)
+ <$> rlpDecode a
+ <*> rlpDecode b
+ <*> rlpDecode c
+ <*> rlpDecode d
+ <*> rlpDecode e
+ <*> rlpDecode f
+ <*> rlpDecode g
+ x -> rlpDecodeFail "Septuple" x
+
+instance
+ ( RLPEncodable a
+ , RLPEncodable b
+ , RLPEncodable c
+ , RLPEncodable d
+ , RLPEncodable e
+ , RLPEncodable f
+ , RLPEncodable g
+ , RLPEncodable h
+ ) => RLPEncodable (a,b,c,d,e,f,g,h) where
+ rlpEncode (a,b,c,d,e,f,g,h) = Array
+ [ rlpEncode a
+ , rlpEncode b
+ , rlpEncode c
+ , rlpEncode d
+ , rlpEncode e
+ , rlpEncode f
+ , rlpEncode g
+ , rlpEncode h
+ ]
+ rlpDecode = \case
+ Array [a,b,c,d,e,f,g,h] -> (,,,,,,,)
+ <$> rlpDecode a
+ <*> rlpDecode b
+ <*> rlpDecode c
+ <*> rlpDecode d
+ <*> rlpDecode e
+ <*> rlpDecode f
+ <*> rlpDecode g
+ <*> rlpDecode h
+ x -> rlpDecodeFail "Octuple" x
+
+instance
+ ( RLPEncodable a
+ , RLPEncodable b
+ , RLPEncodable c
+ , RLPEncodable d
+ , RLPEncodable e
+ , RLPEncodable f
+ , RLPEncodable g
+ , RLPEncodable h
+ , RLPEncodable i
+ ) => RLPEncodable (a,b,c,d,e,f,g,h,i) where
+ rlpEncode (a,b,c,d,e,f,g,h,i) = Array
+ [ rlpEncode a
+ , rlpEncode b
+ , rlpEncode c
+ , rlpEncode d
+ , rlpEncode e
+ , rlpEncode f
+ , rlpEncode g
+ , rlpEncode h
+ , rlpEncode i
+ ]
+ rlpDecode = \case
+ Array [a,b,c,d,e,f,g,h,i] -> (,,,,,,,,)
+ <$> rlpDecode a
+ <*> rlpDecode b
+ <*> rlpDecode c
+ <*> rlpDecode d
+ <*> rlpDecode e
+ <*> rlpDecode f
+ <*> rlpDecode g
+ <*> rlpDecode h
+ <*> rlpDecode i
+ x -> rlpDecodeFail "Nontuple" x
instance RLPEncodable a => RLPEncodable (Maybe a) where
rlpEncode = maybe rlp0 rlpEncode