32
32
33
33
import Control.DeepSeq (NFData )
34
34
import Data.Binary (Binary )
35
+ import Data.Binary qualified as Binary
36
+ import Data.Binary.Get qualified as Binary
37
+ import Data.Binary.Put qualified as Binary
35
38
import Data.ByteString.Short (ShortByteString )
36
39
import Data.ByteString.Short qualified as SBS
37
40
import Data.Choice (Choice )
@@ -96,10 +99,20 @@ data FixityInfo = FixityInfo
96
99
{ -- | Fixity direction
97
100
fiDirection :: FixityDirection ,
98
101
-- | Precedence
99
- fiPrecedence :: Int
102
+ fiPrecedence :: Double
100
103
}
101
104
deriving stock (Eq , Ord , Show , Generic )
102
- deriving anyclass (Binary , NFData )
105
+ deriving anyclass (NFData )
106
+
107
+ instance Binary FixityInfo where
108
+ put FixityInfo {.. } = do
109
+ Binary. put fiDirection
110
+ Binary. putDoublele fiPrecedence
111
+
112
+ get = do
113
+ fiDirection <- Binary. get
114
+ fiPrecedence <- Binary. getDoublele
115
+ pure FixityInfo {.. }
103
116
104
117
-- | Fixity info of the built-in colon data constructor.
105
118
colonFixityInfo :: FixityInfo
@@ -116,13 +129,25 @@ data FixityApproximation = FixityApproximation
116
129
faDirection :: Maybe FixityDirection ,
117
130
-- | Minimum precedence level found in the (maybe conflicting)
118
131
-- definitions for the operator (inclusive)
119
- faMinPrecedence :: Int ,
132
+ faMinPrecedence :: Double ,
120
133
-- | Maximum precedence level found in the (maybe conflicting)
121
134
-- definitions for the operator (inclusive)
122
- faMaxPrecedence :: Int
135
+ faMaxPrecedence :: Double
123
136
}
124
137
deriving stock (Eq , Ord , Show , Generic )
125
- deriving anyclass (Binary , NFData )
138
+ deriving anyclass (NFData )
139
+
140
+ instance Binary FixityApproximation where
141
+ put FixityApproximation {.. } = do
142
+ Binary. put faDirection
143
+ Binary. putDoublele faMinPrecedence
144
+ Binary. putDoublele faMaxPrecedence
145
+
146
+ get = do
147
+ faDirection <- Binary. get
148
+ faMinPrecedence <- Binary. getDoublele
149
+ faMaxPrecedence <- Binary. getDoublele
150
+ pure FixityApproximation {.. }
126
151
127
152
-- | Gives the ability to merge two (maybe conflicting) definitions for an
128
153
-- operator, keeping the higher level of compatible information from both.
0 commit comments