-- | Pretty printing config

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}

module Blockfrost.Pretty.Config
  ( PrettyConfig (..)
  , adaDecimalConf
  , adaSymbol
  , lovelaceDecimalConf
  , testnetConfig
  ) where

import Data.Default (Default (def))
import Data.Proxy (Proxy (..))
import Data.Text (Text)
import qualified Money

-- | Ada Unicode symbol
adaSymbol :: Text
adaSymbol :: Text
adaSymbol = Text
"₳"

-- | Pretty printing configuration
data PrettyConfig = PrettyConfig {
    PrettyConfig -> Bool
pcTestAda             :: Bool -- ^ Set if working with test Ada
  , PrettyConfig -> Bool
pcUnicode             :: Bool -- ^ Set to use unicode symbol for Ada
  , PrettyConfig -> DecimalConf
pcAdaDecimalConf      :: Money.DecimalConf -- ^ Decimal config for printing values over 1 Ada
  , PrettyConfig -> DecimalConf
pcLovelaceDecimalConf :: Money.DecimalConf -- ^ Decimal config for printing lovelace values (<1 Ada)
  }

instance Default PrettyConfig where
  def :: PrettyConfig
def =
    PrettyConfig :: Bool -> Bool -> DecimalConf -> DecimalConf -> PrettyConfig
PrettyConfig {
      pcTestAda :: Bool
pcTestAda = Bool
False
    , pcUnicode :: Bool
pcUnicode = Bool
True
    , pcAdaDecimalConf :: DecimalConf
pcAdaDecimalConf = DecimalConf
adaDecimalConf
    , pcLovelaceDecimalConf :: DecimalConf
pcLovelaceDecimalConf = DecimalConf
lovelaceDecimalConf
    }

-- | `PrettyConfig` for testnet
testnetConfig :: PrettyConfig
testnetConfig :: PrettyConfig
testnetConfig = PrettyConfig
forall a. Default a => a
def { pcTestAda :: Bool
pcTestAda = Bool
True }

-- | Decimal config for printing Ada value
adaDecimalConf :: Money.DecimalConf
adaDecimalConf :: DecimalConf
adaDecimalConf =
  DecimalConf
Money.defaultDecimalConf
    { decimalConf_digits :: Word8
Money.decimalConf_digits = Word8
6
    , decimalConf_separators :: Separators
Money.decimalConf_separators = Separators
Money.separatorsDotNarrownbsp
    , decimalConf_scale :: Scale
Money.decimalConf_scale =
        Proxy '(1, 1) -> Scale
forall (proxy :: (Nat, Nat) -> *) (scale :: (Nat, Nat)).
GoodScale scale =>
proxy scale -> Scale
Money.scale (Proxy (UnitScale "ADA" "ada")
forall k (t :: k). Proxy t
Proxy @(Money.UnitScale "ADA" "ada"))
    }

-- | Decimal config for printing lovelace values
lovelaceDecimalConf :: Money.DecimalConf
lovelaceDecimalConf :: DecimalConf
lovelaceDecimalConf =
  DecimalConf
Money.defaultDecimalConf
    { decimalConf_digits :: Word8
Money.decimalConf_digits = Word8
0
    , decimalConf_separators :: Separators
Money.decimalConf_separators = Separators
Money.separatorsDotNarrownbsp
    , decimalConf_scale :: Scale
Money.decimalConf_scale =
        Proxy '(1000000, 1) -> Scale
forall (proxy :: (Nat, Nat) -> *) (scale :: (Nat, Nat)).
GoodScale scale =>
proxy scale -> Scale
Money.scale (Proxy (UnitScale "ADA" "lovelace")
forall k (t :: k). Proxy t
Proxy @(Money.UnitScale "ADA" "lovelace"))
    }