@@ -33,6 +33,7 @@ module Bfx.Data.Type
33
33
-- $misc
34
34
PltStatus (.. ),
35
35
Error (.. ),
36
+ emptyReq ,
36
37
)
37
38
where
38
39
@@ -235,166 +236,18 @@ newOrderStatus = \case
235
236
-- $trading
236
237
-- Data related to trading and money.
237
238
238
- -- newtype
239
- -- FeeRate
240
- -- (mrel :: MakerOrTaker)
241
- -- (crel :: CurrencyRelation) = FeeRate
242
- -- { unFeeRate :: Rational
243
- -- }
244
- -- deriving newtype
245
- -- ( Eq,
246
- -- Ord,
247
- -- Show
248
- -- )
249
- -- deriving stock
250
- -- ( Generic,
251
- -- TH.Lift
252
- -- )
253
- --
254
- -- instance From (FeeRate mrel crel) Rational
255
- --
256
- -- instance TryFrom Rational (FeeRate mrel crel) where
257
- -- tryFrom x
258
- -- | x >= 0 && x < 1 = Right $ FeeRate x
259
- -- | otherwise = Left $ TryFromException x Nothing
260
- --
261
- -- deriving via
262
- -- Rational
263
- -- instance
264
- -- ( Typeable mrel,
265
- -- Typeable crel
266
- -- ) =>
267
- -- PersistFieldSql (FeeRate mrel crel)
268
- --
269
- -- instance
270
- -- ( Typeable mrel,
271
- -- Typeable crel
272
- -- ) =>
273
- -- PersistField (FeeRate mrel crel)
274
- -- where
275
- -- toPersistValue =
276
- -- PersistRational . from
277
- -- fromPersistValue raw =
278
- -- case raw of
279
- -- PersistRational x ->
280
- -- first (const failure) $ tryFrom x
281
- -- _ ->
282
- -- Left failure
283
- -- where
284
- -- failure =
285
- -- showType @(FeeRate mrel crel)
286
- -- <> " PersistValue is invalid "
287
- -- <> show raw
288
-
289
- newtype RebateRate (mrel :: MakerOrTaker )
290
- = RebateRate Rational
291
- deriving newtype
239
+ newtype RebateRate = RebateRate
240
+ { unRebateRate :: Rational
241
+ }
242
+ deriving stock
292
243
( Eq ,
293
244
Ord ,
294
245
Show ,
295
- Num
296
- )
297
- deriving stock
298
- ( Generic
246
+ Read ,
247
+ Data ,
248
+ Generic
299
249
)
300
250
301
- instance From (RebateRate mrel ) Rational
302
-
303
- instance From Rational (RebateRate mrel )
304
-
305
- -- newtype ProfitRate = ProfitRate
306
- -- { unProfitRate :: Rational
307
- -- }
308
- -- deriving newtype
309
- -- ( Eq,
310
- -- Ord,
311
- -- Show,
312
- -- NFData
313
- -- )
314
- -- deriving stock
315
- -- ( Generic,
316
- -- TH.Lift
317
- -- )
318
- --
319
- -- instance TryFrom Rational ProfitRate where
320
- -- tryFrom x
321
- -- | x > 0 = Right $ ProfitRate x
322
- -- | otherwise = Left $ TryFromException x Nothing
323
- --
324
- -- instance From ProfitRate Rational
325
- --
326
- -- instance FromJSON ProfitRate where
327
- -- parseJSON =
328
- -- withText (inspectType @ProfitRate)
329
- -- $ either (fail . inspect) (pure . ProfitRate)
330
- -- . parseRatio
331
- --
332
- -- newtype ProfitRateB (b :: MinOrMax) = ProfitRateB
333
- -- { unProfitRateB :: ProfitRate
334
- -- }
335
- -- deriving newtype
336
- -- ( Eq,
337
- -- Ord,
338
- -- Show,
339
- -- NFData,
340
- -- FromJSON
341
- -- )
342
- -- deriving stock
343
- -- ( Generic,
344
- -- TH.Lift
345
- -- )
346
-
347
- -- newtype CurrencyCode (crel :: CurrencyRelation) = CurrencyCode
348
- -- { unCurrencyCode :: Text
349
- -- }
350
- -- deriving newtype
351
- -- ( Eq,
352
- -- Ord,
353
- -- Show,
354
- -- ToJSON,
355
- -- NFData
356
- -- )
357
- -- deriving stock
358
- -- ( Generic,
359
- -- TH.Lift
360
- -- )
361
- --
362
- -- instance From (CurrencyCode crel0) (CurrencyCode crel1)
363
- --
364
- -- instance (Typeable crel) => FromJSON (CurrencyCode crel) where
365
- -- parseJSON = withText
366
- -- (showType @(CurrencyCode crel))
367
- -- $ \raw -> do
368
- -- case newCurrencyCode raw of
369
- -- Left x -> fail $ show x
370
- -- Right x -> pure x
371
- --
372
- -- deriving via
373
- -- Text
374
- -- instance
375
- -- ( Typeable crel
376
- -- ) =>
377
- -- PersistFieldSql (CurrencyCode crel)
378
- --
379
- -- instance
380
- -- ( Typeable crel
381
- -- ) =>
382
- -- PersistField (CurrencyCode crel)
383
- -- where
384
- -- toPersistValue =
385
- -- PersistText . coerce
386
- -- fromPersistValue raw =
387
- -- case raw of
388
- -- PersistText x ->
389
- -- first (const failure) $ newCurrencyCode x
390
- -- _ ->
391
- -- Left failure
392
- -- where
393
- -- failure =
394
- -- showType @(CurrencyCode crel)
395
- -- <> " PersistValue is invalid "
396
- -- <> show raw
397
-
398
251
newCurrencyCode :: (MonadThrow m ) => Text -> m CurrencyCode
399
252
newCurrencyCode raw =
400
253
case T. strip raw of
@@ -576,3 +429,6 @@ data Error
576
429
)
577
430
578
431
instance Exception Error
432
+
433
+ emptyReq :: Map Int Int
434
+ emptyReq = mempty
0 commit comments