@@ -133,3 +133,93 @@ instance TestEquality (Sing :: GainOrLose -> Type) where
133
133
testEquality SGain SGain = Just Refl
134
134
testEquality SLose SLose = Just Refl
135
135
testEquality _ _ = Nothing
136
+
137
+ --
138
+ -- BaseOrQuote
139
+ --
140
+
141
+ data instance Sing (x :: BaseOrQuote ) where
142
+ SBase :: Sing 'Base
143
+ SQuote :: Sing 'Quote
144
+
145
+ instance SingKind BaseOrQuote where
146
+ type Demote BaseOrQuote = BaseOrQuote
147
+ fromSing SBase = Base
148
+ fromSing SQuote = Quote
149
+ toSing Base = SomeSing SBase
150
+ toSing Quote = SomeSing SQuote
151
+
152
+ instance SingI 'Base where sing = SBase
153
+
154
+ instance SingI 'Quote where sing = SQuote
155
+
156
+ instance TestEquality (Sing :: BaseOrQuote -> Type ) where
157
+ testEquality SBase SBase = Just Refl
158
+ testEquality SQuote SQuote = Just Refl
159
+ testEquality _ _ = Nothing
160
+
161
+ --
162
+ -- MoneyKind
163
+ --
164
+
165
+ data instance Sing (x :: MoneyKind ) where
166
+ SMoneyAmount :: Sing 'MoneyAmount
167
+ SCurrency :: Sing 'Currency
168
+ SQuotePerBase :: Sing 'QuotePerBase
169
+ SFeeRate :: Sing 'FeeRate
170
+ SProfitRate :: Sing 'ProfitRate
171
+
172
+ instance SingKind MoneyKind where
173
+ type Demote MoneyKind = MoneyKind
174
+ fromSing SMoneyAmount = MoneyAmount
175
+ fromSing SCurrency = Currency
176
+ fromSing SQuotePerBase = QuotePerBase
177
+ fromSing SFeeRate = FeeRate
178
+ fromSing SProfitRate = ProfitRate
179
+ toSing MoneyAmount = SomeSing SMoneyAmount
180
+ toSing Currency = SomeSing SCurrency
181
+ toSing QuotePerBase = SomeSing SQuotePerBase
182
+ toSing FeeRate = SomeSing SFeeRate
183
+ toSing ProfitRate = SomeSing SProfitRate
184
+
185
+ instance SingI 'MoneyAmount where sing = SMoneyAmount
186
+
187
+ instance SingI 'Currency where sing = SCurrency
188
+
189
+ instance SingI 'QuotePerBase where sing = SQuotePerBase
190
+
191
+ instance SingI 'FeeRate where sing = SFeeRate
192
+
193
+ instance SingI 'ProfitRate where sing = SProfitRate
194
+
195
+ instance TestEquality (Sing :: MoneyKind -> Type ) where
196
+ testEquality SMoneyAmount SMoneyAmount = Just Refl
197
+ testEquality SCurrency SCurrency = Just Refl
198
+ testEquality SQuotePerBase SQuotePerBase = Just Refl
199
+ testEquality SFeeRate SFeeRate = Just Refl
200
+ testEquality SProfitRate SProfitRate = Just Refl
201
+ testEquality _ _ = Nothing
202
+
203
+ --
204
+ -- MakerOrTaker
205
+ --
206
+
207
+ data instance Sing (x :: MakerOrTaker ) where
208
+ SMaker :: Sing 'Maker
209
+ STaker :: Sing 'Taker
210
+
211
+ instance SingKind MakerOrTaker where
212
+ type Demote MakerOrTaker = MakerOrTaker
213
+ fromSing SMaker = Maker
214
+ fromSing STaker = Taker
215
+ toSing Maker = SomeSing SMaker
216
+ toSing Taker = SomeSing STaker
217
+
218
+ instance SingI 'Maker where sing = SMaker
219
+
220
+ instance SingI 'Taker where sing = STaker
221
+
222
+ instance TestEquality (Sing :: MakerOrTaker -> Type ) where
223
+ testEquality SMaker SMaker = Just Refl
224
+ testEquality STaker STaker = Just Refl
225
+ testEquality _ _ = Nothing
0 commit comments