on master help sign in
Add binary instance for Regions
commit22300f3719f755a6e0baa4cdb46cc10da5b291a2 authorEvan Czaplicki <evancz@users.noreply.github.com> dateTue 28 Mar 2017, 14:03 (10 years ago) parentc987f07
1 file changed+27
src/Reporting/Region.hs+27
src/Reporting/Region.hs+27
@@ -3,6 +3,11 @@ module Reporting.Region where
33
44import Data.Aeson ((.=))
55import qualified Data.Aeson as Json
6+import Data.Binary
7+
8+
9+
10+-- REGION
611
712
813data Region =
@@ -60,3 +65,25 @@ instance Json.ToJSON Position where
6065 [ "line" .= line
6166 , "column" .= column
6267 ]
68+
69+
70+
71+-- BINARY
72+
73+
74+instance Binary Region where
75+ get =
76+ Region <$> get <*> get
77+
78+ put (Region start end) =
79+ do put start
80+ put end
81+
82+
83+instance Binary Position where
84+ get =
85+ Position <$> get <*> get
86+
87+ put (Position line column) =
88+ do put line
89+ put column