{-# LANGUAGE RankNTypes #-}
module Mcmc.Monitor.Parameter
( MonitorParameter (..),
monitorInt,
monitorRealFloat,
monitorRealFloatF,
monitorRealFloatS,
)
where
import Data.Text.Lazy.Builder (Builder)
import qualified Data.Text.Lazy.Builder.Int as T
import qualified Data.Text.Lazy.Builder.RealFloat as T
import Lens.Micro
data MonitorParameter a
= MonitorParameter
{
mpName :: String,
mpFunc :: a -> Builder
}
monitorInt ::
Integral b =>
String ->
Lens' a b ->
MonitorParameter a
monitorInt n l = MonitorParameter n (\x -> T.decimal $ x ^. l)
{-# SPECIALIZE monitorInt :: String -> Lens' a Int -> MonitorParameter a #-}
monitorRealFloat ::
RealFloat b =>
String ->
Lens' a b ->
MonitorParameter a
monitorRealFloat n l =
MonitorParameter n (\x -> T.formatRealFloat T.Fixed (Just 8) $ x ^. l)
{-# SPECIALIZE monitorRealFloat :: String -> Lens' a Double -> MonitorParameter a #-}
monitorRealFloatF ::
RealFloat b =>
String ->
Lens' a b ->
MonitorParameter a
monitorRealFloatF n l = MonitorParameter n (\x -> T.realFloat $ x ^. l)
{-# SPECIALIZE monitorRealFloatF :: String -> Lens' a Double -> MonitorParameter a #-}
monitorRealFloatS ::
RealFloat b =>
String ->
Lens' a b ->
MonitorParameter a
monitorRealFloatS n l =
MonitorParameter
n
(\x -> T.formatRealFloat T.Exponent (Just 8) $ x ^. l)
{-# SPECIALIZE monitorRealFloatS :: String -> Lens' a Double -> MonitorParameter a #-}