-
-
Save 21it/c6b510261c34a36b6329c11c17ce3833 to your computer and use it in GitHub Desktop.
haskell.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeApplications #-} | |
{-# OPTIONS_HADDOCK show-extensions #-} | |
module BitfinexClient.Class.BfxRound | |
( bfxRound, | |
) | |
where | |
import BitfinexClient.Data.Kind | |
import BitfinexClient.Data.Metro | |
import BitfinexClient.Import.External | |
class (From a Rational, TryFrom Rational a) => BfxRound a where | |
bfxRound' :: a -> Either (TryFromException Rational a) a | |
instance BfxRound (QuotePerBase act) where | |
bfxRound' = | |
tryFrom | |
. sdRound 5 | |
. dpRound 8 | |
. from | |
instance BfxRound (MoneyAmt dim act pre) where | |
bfxRound' = | |
tryFrom | |
. dpRound 8 | |
. from | |
{- | |
• Couldn't match representation of type: a 'UnRounded | |
with that of: a 'Rounded | |
arising from a use of ‘coerce’ | |
NB: We cannot know what roles the parameters to ‘a’ have; | |
we must assume that the role is nominal | |
• In the first argument of ‘(.)’, namely ‘coerce’ | |
In the expression: coerce . bfxRound' | |
In an equation for ‘bfxRound’: bfxRound = coerce . bfxRound' | |
• Relevant bindings include | |
bfxRound :: a 'UnRounded | |
-> Either (TryFromException Rational (a 'Rounded)) | |
(a 'Rounded) | |
(bound at /app/bitfinex-client/src/BitfinexClient/Class/BfxRoun | |
d.hs:35:1) | |
| | |
36 | coerce | |
| ^^^^^^ | |
-} | |
bfxRound :: | |
forall a. | |
( BfxRound (a 'UnRounded) | |
) => | |
a 'UnRounded -> | |
Either (TryFromException Rational (a 'Rounded)) (a 'Rounded) | |
bfxRound = | |
coerce | |
. bfxRound' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment