{-# LANGUAGE TemplateHaskell #-}
module Language.Drasil.Printing.PrintingInformation where
import Control.Lens (makeLenses, Lens', (^.))
import SysInfo.Drasil (sysinfodb, SystemInformation)
import Database.Drasil (ChunkDB)
import Language.Drasil (Stage(..))
data Notation = Scientific
| Engineering
class HasPrintingOptions c where
getSetting :: Lens' c Notation
newtype PrintingConfiguration = PC { PrintingConfiguration -> Notation
_notation :: Notation }
makeLenses ''PrintingConfiguration
instance HasPrintingOptions PrintingConfiguration where getSetting :: Lens' PrintingConfiguration Notation
getSetting = (Notation -> f Notation)
-> PrintingConfiguration -> f PrintingConfiguration
Iso' PrintingConfiguration Notation
notation
data PrintingInformation = PI
{ PrintingInformation -> ChunkDB
_ckdb :: ChunkDB
, PrintingInformation -> Stage
_stg :: Stage
, PrintingInformation -> PrintingConfiguration
_configuration :: PrintingConfiguration
}
makeLenses ''PrintingInformation
instance HasPrintingOptions PrintingInformation where getSetting :: Lens' PrintingInformation Notation
getSetting = (PrintingConfiguration -> f PrintingConfiguration)
-> PrintingInformation -> f PrintingInformation
Lens' PrintingInformation PrintingConfiguration
configuration ((PrintingConfiguration -> f PrintingConfiguration)
-> PrintingInformation -> f PrintingInformation)
-> ((Notation -> f Notation)
-> PrintingConfiguration -> f PrintingConfiguration)
-> (Notation -> f Notation)
-> PrintingInformation
-> f PrintingInformation
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Notation -> f Notation)
-> PrintingConfiguration -> f PrintingConfiguration
forall c. HasPrintingOptions c => Lens' c Notation
Lens' PrintingConfiguration Notation
getSetting
piSys :: SystemInformation -> Stage -> PrintingConfiguration -> PrintingInformation
piSys :: SystemInformation
-> Stage -> PrintingConfiguration -> PrintingInformation
piSys SystemInformation
si = ChunkDB -> Stage -> PrintingConfiguration -> PrintingInformation
PI (SystemInformation
si SystemInformation
-> Getting ChunkDB SystemInformation ChunkDB -> ChunkDB
forall s a. s -> Getting a s a -> a
^. Getting ChunkDB SystemInformation ChunkDB
forall c. HasSystemInformation c => Lens' c ChunkDB
Lens' SystemInformation ChunkDB
sysinfodb)
defaultConfiguration :: PrintingConfiguration
defaultConfiguration :: PrintingConfiguration
defaultConfiguration = Notation -> PrintingConfiguration
PC Notation
Engineering