Skip to content

Instantly share code, notes, and snippets.

@21it

21it/haskell.hs Secret

Created December 24, 2021 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 21it/c6b510261c34a36b6329c11c17ce3833 to your computer and use it in GitHub Desktop.
Save 21it/c6b510261c34a36b6329c11c17ce3833 to your computer and use it in GitHub Desktop.
haskell.hs
{-# 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