{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
module Codec.Xlsx.Types.ConditionalFormatting
( ConditionalFormatting
, CfRule(..)
, NStdDev(..)
, Inclusion(..)
, CfValue(..)
, MinCfValue(..)
, MaxCfValue(..)
, Condition(..)
, OperatorExpression(..)
, TimePeriod(..)
, IconSetOptions(..)
, IconSetType(..)
, DataBarOptions(..)
, dataBarWithColor
, cfrCondition
, cfrDxfId
, cfrPriority
, cfrStopIfTrue
, isoIconSet
, isoValues
, isoReverse
, isoShowValue
, dboMaxLength
, dboMinLength
, dboShowValue
, dboMinimum
, dboMaximum
, dboColor
, topCfPriority
) where
import Control.Arrow (first, right)
import Control.DeepSeq (NFData)
#ifdef USE_MICROLENS
import Lens.Micro.TH (makeLenses)
#else
import Control.Lens (makeLenses)
#endif
import Data.Bool (bool)
import Data.ByteString (ByteString)
import Data.Default
import Data.Map (Map)
import qualified Data.Map as M
import Data.Maybe
import Data.Monoid ((<>))
import Data.Text (Text)
import qualified Data.Text as T
import GHC.Generics (Generic)
import Text.XML
import Text.XML.Cursor hiding (bool)
import qualified Xeno.DOM as Xeno
import Codec.Xlsx.Parser.Internal
import Codec.Xlsx.Types.Common
import Codec.Xlsx.Types.StyleSheet (Color)
import Codec.Xlsx.Writer.Internal
data OperatorExpression
= OpBeginsWith Formula
| OpBetween Formula Formula
| OpContainsText Formula
| OpEndsWith Formula
| OpEqual Formula
| OpGreaterThan Formula
| OpGreaterThanOrEqual Formula
| OpLessThan Formula
| OpLessThanOrEqual Formula
| OpNotBetween Formula Formula
| OpNotContains Formula
| OpNotEqual Formula
deriving (OperatorExpression -> OperatorExpression -> Bool
(OperatorExpression -> OperatorExpression -> Bool)
-> (OperatorExpression -> OperatorExpression -> Bool)
-> Eq OperatorExpression
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OperatorExpression -> OperatorExpression -> Bool
== :: OperatorExpression -> OperatorExpression -> Bool
$c/= :: OperatorExpression -> OperatorExpression -> Bool
/= :: OperatorExpression -> OperatorExpression -> Bool
Eq, Eq OperatorExpression
Eq OperatorExpression =>
(OperatorExpression -> OperatorExpression -> Ordering)
-> (OperatorExpression -> OperatorExpression -> Bool)
-> (OperatorExpression -> OperatorExpression -> Bool)
-> (OperatorExpression -> OperatorExpression -> Bool)
-> (OperatorExpression -> OperatorExpression -> Bool)
-> (OperatorExpression -> OperatorExpression -> OperatorExpression)
-> (OperatorExpression -> OperatorExpression -> OperatorExpression)
-> Ord OperatorExpression
OperatorExpression -> OperatorExpression -> Bool
OperatorExpression -> OperatorExpression -> Ordering
OperatorExpression -> OperatorExpression -> OperatorExpression
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: OperatorExpression -> OperatorExpression -> Ordering
compare :: OperatorExpression -> OperatorExpression -> Ordering
$c< :: OperatorExpression -> OperatorExpression -> Bool
< :: OperatorExpression -> OperatorExpression -> Bool
$c<= :: OperatorExpression -> OperatorExpression -> Bool
<= :: OperatorExpression -> OperatorExpression -> Bool
$c> :: OperatorExpression -> OperatorExpression -> Bool
> :: OperatorExpression -> OperatorExpression -> Bool
$c>= :: OperatorExpression -> OperatorExpression -> Bool
>= :: OperatorExpression -> OperatorExpression -> Bool
$cmax :: OperatorExpression -> OperatorExpression -> OperatorExpression
max :: OperatorExpression -> OperatorExpression -> OperatorExpression
$cmin :: OperatorExpression -> OperatorExpression -> OperatorExpression
min :: OperatorExpression -> OperatorExpression -> OperatorExpression
Ord, Int -> OperatorExpression -> ShowS
[OperatorExpression] -> ShowS
OperatorExpression -> [Char]
(Int -> OperatorExpression -> ShowS)
-> (OperatorExpression -> [Char])
-> ([OperatorExpression] -> ShowS)
-> Show OperatorExpression
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OperatorExpression -> ShowS
showsPrec :: Int -> OperatorExpression -> ShowS
$cshow :: OperatorExpression -> [Char]
show :: OperatorExpression -> [Char]
$cshowList :: [OperatorExpression] -> ShowS
showList :: [OperatorExpression] -> ShowS
Show, (forall x. OperatorExpression -> Rep OperatorExpression x)
-> (forall x. Rep OperatorExpression x -> OperatorExpression)
-> Generic OperatorExpression
forall x. Rep OperatorExpression x -> OperatorExpression
forall x. OperatorExpression -> Rep OperatorExpression x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. OperatorExpression -> Rep OperatorExpression x
from :: forall x. OperatorExpression -> Rep OperatorExpression x
$cto :: forall x. Rep OperatorExpression x -> OperatorExpression
to :: forall x. Rep OperatorExpression x -> OperatorExpression
Generic)
instance NFData OperatorExpression
data TimePeriod
= PerLast7Days
| PerLastMonth
| PerLastWeek
| PerNextMonth
| PerNextWeek
| PerThisMonth
| PerThisWeek
| PerToday
| PerTomorrow
| PerYesterday
deriving (TimePeriod -> TimePeriod -> Bool
(TimePeriod -> TimePeriod -> Bool)
-> (TimePeriod -> TimePeriod -> Bool) -> Eq TimePeriod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TimePeriod -> TimePeriod -> Bool
== :: TimePeriod -> TimePeriod -> Bool
$c/= :: TimePeriod -> TimePeriod -> Bool
/= :: TimePeriod -> TimePeriod -> Bool
Eq, Eq TimePeriod
Eq TimePeriod =>
(TimePeriod -> TimePeriod -> Ordering)
-> (TimePeriod -> TimePeriod -> Bool)
-> (TimePeriod -> TimePeriod -> Bool)
-> (TimePeriod -> TimePeriod -> Bool)
-> (TimePeriod -> TimePeriod -> Bool)
-> (TimePeriod -> TimePeriod -> TimePeriod)
-> (TimePeriod -> TimePeriod -> TimePeriod)
-> Ord TimePeriod
TimePeriod -> TimePeriod -> Bool
TimePeriod -> TimePeriod -> Ordering
TimePeriod -> TimePeriod -> TimePeriod
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: TimePeriod -> TimePeriod -> Ordering
compare :: TimePeriod -> TimePeriod -> Ordering
$c< :: TimePeriod -> TimePeriod -> Bool
< :: TimePeriod -> TimePeriod -> Bool
$c<= :: TimePeriod -> TimePeriod -> Bool
<= :: TimePeriod -> TimePeriod -> Bool
$c> :: TimePeriod -> TimePeriod -> Bool
> :: TimePeriod -> TimePeriod -> Bool
$c>= :: TimePeriod -> TimePeriod -> Bool
>= :: TimePeriod -> TimePeriod -> Bool
$cmax :: TimePeriod -> TimePeriod -> TimePeriod
max :: TimePeriod -> TimePeriod -> TimePeriod
$cmin :: TimePeriod -> TimePeriod -> TimePeriod
min :: TimePeriod -> TimePeriod -> TimePeriod
Ord, Int -> TimePeriod -> ShowS
[TimePeriod] -> ShowS
TimePeriod -> [Char]
(Int -> TimePeriod -> ShowS)
-> (TimePeriod -> [Char])
-> ([TimePeriod] -> ShowS)
-> Show TimePeriod
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TimePeriod -> ShowS
showsPrec :: Int -> TimePeriod -> ShowS
$cshow :: TimePeriod -> [Char]
show :: TimePeriod -> [Char]
$cshowList :: [TimePeriod] -> ShowS
showList :: [TimePeriod] -> ShowS
Show, (forall x. TimePeriod -> Rep TimePeriod x)
-> (forall x. Rep TimePeriod x -> TimePeriod) -> Generic TimePeriod
forall x. Rep TimePeriod x -> TimePeriod
forall x. TimePeriod -> Rep TimePeriod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TimePeriod -> Rep TimePeriod x
from :: forall x. TimePeriod -> Rep TimePeriod x
$cto :: forall x. Rep TimePeriod x -> TimePeriod
to :: forall x. Rep TimePeriod x -> TimePeriod
Generic)
instance NFData TimePeriod
data Inclusion
= Inclusive
| Exclusive
deriving (Inclusion -> Inclusion -> Bool
(Inclusion -> Inclusion -> Bool)
-> (Inclusion -> Inclusion -> Bool) -> Eq Inclusion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Inclusion -> Inclusion -> Bool
== :: Inclusion -> Inclusion -> Bool
$c/= :: Inclusion -> Inclusion -> Bool
/= :: Inclusion -> Inclusion -> Bool
Eq, Eq Inclusion
Eq Inclusion =>
(Inclusion -> Inclusion -> Ordering)
-> (Inclusion -> Inclusion -> Bool)
-> (Inclusion -> Inclusion -> Bool)
-> (Inclusion -> Inclusion -> Bool)
-> (Inclusion -> Inclusion -> Bool)
-> (Inclusion -> Inclusion -> Inclusion)
-> (Inclusion -> Inclusion -> Inclusion)
-> Ord Inclusion
Inclusion -> Inclusion -> Bool
Inclusion -> Inclusion -> Ordering
Inclusion -> Inclusion -> Inclusion
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Inclusion -> Inclusion -> Ordering
compare :: Inclusion -> Inclusion -> Ordering
$c< :: Inclusion -> Inclusion -> Bool
< :: Inclusion -> Inclusion -> Bool
$c<= :: Inclusion -> Inclusion -> Bool
<= :: Inclusion -> Inclusion -> Bool
$c> :: Inclusion -> Inclusion -> Bool
> :: Inclusion -> Inclusion -> Bool
$c>= :: Inclusion -> Inclusion -> Bool
>= :: Inclusion -> Inclusion -> Bool
$cmax :: Inclusion -> Inclusion -> Inclusion
max :: Inclusion -> Inclusion -> Inclusion
$cmin :: Inclusion -> Inclusion -> Inclusion
min :: Inclusion -> Inclusion -> Inclusion
Ord, Int -> Inclusion -> ShowS
[Inclusion] -> ShowS
Inclusion -> [Char]
(Int -> Inclusion -> ShowS)
-> (Inclusion -> [Char])
-> ([Inclusion] -> ShowS)
-> Show Inclusion
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Inclusion -> ShowS
showsPrec :: Int -> Inclusion -> ShowS
$cshow :: Inclusion -> [Char]
show :: Inclusion -> [Char]
$cshowList :: [Inclusion] -> ShowS
showList :: [Inclusion] -> ShowS
Show, (forall x. Inclusion -> Rep Inclusion x)
-> (forall x. Rep Inclusion x -> Inclusion) -> Generic Inclusion
forall x. Rep Inclusion x -> Inclusion
forall x. Inclusion -> Rep Inclusion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Inclusion -> Rep Inclusion x
from :: forall x. Inclusion -> Rep Inclusion x
$cto :: forall x. Rep Inclusion x -> Inclusion
to :: forall x. Rep Inclusion x -> Inclusion
Generic)
instance NFData Inclusion
newtype NStdDev =
NStdDev Int
deriving (NStdDev -> NStdDev -> Bool
(NStdDev -> NStdDev -> Bool)
-> (NStdDev -> NStdDev -> Bool) -> Eq NStdDev
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NStdDev -> NStdDev -> Bool
== :: NStdDev -> NStdDev -> Bool
$c/= :: NStdDev -> NStdDev -> Bool
/= :: NStdDev -> NStdDev -> Bool
Eq, Eq NStdDev
Eq NStdDev =>
(NStdDev -> NStdDev -> Ordering)
-> (NStdDev -> NStdDev -> Bool)
-> (NStdDev -> NStdDev -> Bool)
-> (NStdDev -> NStdDev -> Bool)
-> (NStdDev -> NStdDev -> Bool)
-> (NStdDev -> NStdDev -> NStdDev)
-> (NStdDev -> NStdDev -> NStdDev)
-> Ord NStdDev
NStdDev -> NStdDev -> Bool
NStdDev -> NStdDev -> Ordering
NStdDev -> NStdDev -> NStdDev
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: NStdDev -> NStdDev -> Ordering
compare :: NStdDev -> NStdDev -> Ordering
$c< :: NStdDev -> NStdDev -> Bool
< :: NStdDev -> NStdDev -> Bool
$c<= :: NStdDev -> NStdDev -> Bool
<= :: NStdDev -> NStdDev -> Bool
$c> :: NStdDev -> NStdDev -> Bool
> :: NStdDev -> NStdDev -> Bool
$c>= :: NStdDev -> NStdDev -> Bool
>= :: NStdDev -> NStdDev -> Bool
$cmax :: NStdDev -> NStdDev -> NStdDev
max :: NStdDev -> NStdDev -> NStdDev
$cmin :: NStdDev -> NStdDev -> NStdDev
min :: NStdDev -> NStdDev -> NStdDev
Ord, Int -> NStdDev -> ShowS
[NStdDev] -> ShowS
NStdDev -> [Char]
(Int -> NStdDev -> ShowS)
-> (NStdDev -> [Char]) -> ([NStdDev] -> ShowS) -> Show NStdDev
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NStdDev -> ShowS
showsPrec :: Int -> NStdDev -> ShowS
$cshow :: NStdDev -> [Char]
show :: NStdDev -> [Char]
$cshowList :: [NStdDev] -> ShowS
showList :: [NStdDev] -> ShowS
Show, (forall x. NStdDev -> Rep NStdDev x)
-> (forall x. Rep NStdDev x -> NStdDev) -> Generic NStdDev
forall x. Rep NStdDev x -> NStdDev
forall x. NStdDev -> Rep NStdDev x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NStdDev -> Rep NStdDev x
from :: forall x. NStdDev -> Rep NStdDev x
$cto :: forall x. Rep NStdDev x -> NStdDev
to :: forall x. Rep NStdDev x -> NStdDev
Generic)
instance NFData NStdDev
data Condition
= AboveAverage Inclusion (Maybe NStdDev)
| BeginsWith Text
| BelowAverage Inclusion (Maybe NStdDev)
| BottomNPercent Int
| BottomNValues Int
| CellIs OperatorExpression
| ColorScale2 MinCfValue Color MaxCfValue Color
| ColorScale3 MinCfValue Color CfValue Color MaxCfValue Color
| ContainsBlanks
| ContainsErrors
| ContainsText Text
| DataBar DataBarOptions
| DoesNotContainErrors
| DoesNotContainBlanks
| DoesNotContainText Text
| DuplicateValues
| EndsWith Text
| Expression Formula
| IconSet IconSetOptions
| InTimePeriod TimePeriod
| TopNPercent Int
| TopNValues Int
| UniqueValues
deriving (Condition -> Condition -> Bool
(Condition -> Condition -> Bool)
-> (Condition -> Condition -> Bool) -> Eq Condition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Condition -> Condition -> Bool
== :: Condition -> Condition -> Bool
$c/= :: Condition -> Condition -> Bool
/= :: Condition -> Condition -> Bool
Eq, Eq Condition
Eq Condition =>
(Condition -> Condition -> Ordering)
-> (Condition -> Condition -> Bool)
-> (Condition -> Condition -> Bool)
-> (Condition -> Condition -> Bool)
-> (Condition -> Condition -> Bool)
-> (Condition -> Condition -> Condition)
-> (Condition -> Condition -> Condition)
-> Ord Condition
Condition -> Condition -> Bool
Condition -> Condition -> Ordering
Condition -> Condition -> Condition
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Condition -> Condition -> Ordering
compare :: Condition -> Condition -> Ordering
$c< :: Condition -> Condition -> Bool
< :: Condition -> Condition -> Bool
$c<= :: Condition -> Condition -> Bool
<= :: Condition -> Condition -> Bool
$c> :: Condition -> Condition -> Bool
> :: Condition -> Condition -> Bool
$c>= :: Condition -> Condition -> Bool
>= :: Condition -> Condition -> Bool
$cmax :: Condition -> Condition -> Condition
max :: Condition -> Condition -> Condition
$cmin :: Condition -> Condition -> Condition
min :: Condition -> Condition -> Condition
Ord, Int -> Condition -> ShowS
[Condition] -> ShowS
Condition -> [Char]
(Int -> Condition -> ShowS)
-> (Condition -> [Char])
-> ([Condition] -> ShowS)
-> Show Condition
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Condition -> ShowS
showsPrec :: Int -> Condition -> ShowS
$cshow :: Condition -> [Char]
show :: Condition -> [Char]
$cshowList :: [Condition] -> ShowS
showList :: [Condition] -> ShowS
Show, (forall x. Condition -> Rep Condition x)
-> (forall x. Rep Condition x -> Condition) -> Generic Condition
forall x. Rep Condition x -> Condition
forall x. Condition -> Rep Condition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Condition -> Rep Condition x
from :: forall x. Condition -> Rep Condition x
$cto :: forall x. Rep Condition x -> Condition
to :: forall x. Rep Condition x -> Condition
Generic)
instance NFData Condition
data CfValue
= CfValue Double
| CfPercent Double
| CfPercentile Double
| CfFormula Formula
deriving (CfValue -> CfValue -> Bool
(CfValue -> CfValue -> Bool)
-> (CfValue -> CfValue -> Bool) -> Eq CfValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CfValue -> CfValue -> Bool
== :: CfValue -> CfValue -> Bool
$c/= :: CfValue -> CfValue -> Bool
/= :: CfValue -> CfValue -> Bool
Eq, Eq CfValue
Eq CfValue =>
(CfValue -> CfValue -> Ordering)
-> (CfValue -> CfValue -> Bool)
-> (CfValue -> CfValue -> Bool)
-> (CfValue -> CfValue -> Bool)
-> (CfValue -> CfValue -> Bool)
-> (CfValue -> CfValue -> CfValue)
-> (CfValue -> CfValue -> CfValue)
-> Ord CfValue
CfValue -> CfValue -> Bool
CfValue -> CfValue -> Ordering
CfValue -> CfValue -> CfValue
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: CfValue -> CfValue -> Ordering
compare :: CfValue -> CfValue -> Ordering
$c< :: CfValue -> CfValue -> Bool
< :: CfValue -> CfValue -> Bool
$c<= :: CfValue -> CfValue -> Bool
<= :: CfValue -> CfValue -> Bool
$c> :: CfValue -> CfValue -> Bool
> :: CfValue -> CfValue -> Bool
$c>= :: CfValue -> CfValue -> Bool
>= :: CfValue -> CfValue -> Bool
$cmax :: CfValue -> CfValue -> CfValue
max :: CfValue -> CfValue -> CfValue
$cmin :: CfValue -> CfValue -> CfValue
min :: CfValue -> CfValue -> CfValue
Ord, Int -> CfValue -> ShowS
[CfValue] -> ShowS
CfValue -> [Char]
(Int -> CfValue -> ShowS)
-> (CfValue -> [Char]) -> ([CfValue] -> ShowS) -> Show CfValue
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CfValue -> ShowS
showsPrec :: Int -> CfValue -> ShowS
$cshow :: CfValue -> [Char]
show :: CfValue -> [Char]
$cshowList :: [CfValue] -> ShowS
showList :: [CfValue] -> ShowS
Show, (forall x. CfValue -> Rep CfValue x)
-> (forall x. Rep CfValue x -> CfValue) -> Generic CfValue
forall x. Rep CfValue x -> CfValue
forall x. CfValue -> Rep CfValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CfValue -> Rep CfValue x
from :: forall x. CfValue -> Rep CfValue x
$cto :: forall x. Rep CfValue x -> CfValue
to :: forall x. Rep CfValue x -> CfValue
Generic)
instance NFData CfValue
data MinCfValue
= CfvMin
| MinCfValue CfValue
deriving (MinCfValue -> MinCfValue -> Bool
(MinCfValue -> MinCfValue -> Bool)
-> (MinCfValue -> MinCfValue -> Bool) -> Eq MinCfValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MinCfValue -> MinCfValue -> Bool
== :: MinCfValue -> MinCfValue -> Bool
$c/= :: MinCfValue -> MinCfValue -> Bool
/= :: MinCfValue -> MinCfValue -> Bool
Eq, Eq MinCfValue
Eq MinCfValue =>
(MinCfValue -> MinCfValue -> Ordering)
-> (MinCfValue -> MinCfValue -> Bool)
-> (MinCfValue -> MinCfValue -> Bool)
-> (MinCfValue -> MinCfValue -> Bool)
-> (MinCfValue -> MinCfValue -> Bool)
-> (MinCfValue -> MinCfValue -> MinCfValue)
-> (MinCfValue -> MinCfValue -> MinCfValue)
-> Ord MinCfValue
MinCfValue -> MinCfValue -> Bool
MinCfValue -> MinCfValue -> Ordering
MinCfValue -> MinCfValue -> MinCfValue
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: MinCfValue -> MinCfValue -> Ordering
compare :: MinCfValue -> MinCfValue -> Ordering
$c< :: MinCfValue -> MinCfValue -> Bool
< :: MinCfValue -> MinCfValue -> Bool
$c<= :: MinCfValue -> MinCfValue -> Bool
<= :: MinCfValue -> MinCfValue -> Bool
$c> :: MinCfValue -> MinCfValue -> Bool
> :: MinCfValue -> MinCfValue -> Bool
$c>= :: MinCfValue -> MinCfValue -> Bool
>= :: MinCfValue -> MinCfValue -> Bool
$cmax :: MinCfValue -> MinCfValue -> MinCfValue
max :: MinCfValue -> MinCfValue -> MinCfValue
$cmin :: MinCfValue -> MinCfValue -> MinCfValue
min :: MinCfValue -> MinCfValue -> MinCfValue
Ord, Int -> MinCfValue -> ShowS
[MinCfValue] -> ShowS
MinCfValue -> [Char]
(Int -> MinCfValue -> ShowS)
-> (MinCfValue -> [Char])
-> ([MinCfValue] -> ShowS)
-> Show MinCfValue
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MinCfValue -> ShowS
showsPrec :: Int -> MinCfValue -> ShowS
$cshow :: MinCfValue -> [Char]
show :: MinCfValue -> [Char]
$cshowList :: [MinCfValue] -> ShowS
showList :: [MinCfValue] -> ShowS
Show, (forall x. MinCfValue -> Rep MinCfValue x)
-> (forall x. Rep MinCfValue x -> MinCfValue) -> Generic MinCfValue
forall x. Rep MinCfValue x -> MinCfValue
forall x. MinCfValue -> Rep MinCfValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MinCfValue -> Rep MinCfValue x
from :: forall x. MinCfValue -> Rep MinCfValue x
$cto :: forall x. Rep MinCfValue x -> MinCfValue
to :: forall x. Rep MinCfValue x -> MinCfValue
Generic)
instance NFData MinCfValue
data MaxCfValue
= CfvMax
| MaxCfValue CfValue
deriving (MaxCfValue -> MaxCfValue -> Bool
(MaxCfValue -> MaxCfValue -> Bool)
-> (MaxCfValue -> MaxCfValue -> Bool) -> Eq MaxCfValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MaxCfValue -> MaxCfValue -> Bool
== :: MaxCfValue -> MaxCfValue -> Bool
$c/= :: MaxCfValue -> MaxCfValue -> Bool
/= :: MaxCfValue -> MaxCfValue -> Bool
Eq, Eq MaxCfValue
Eq MaxCfValue =>
(MaxCfValue -> MaxCfValue -> Ordering)
-> (MaxCfValue -> MaxCfValue -> Bool)
-> (MaxCfValue -> MaxCfValue -> Bool)
-> (MaxCfValue -> MaxCfValue -> Bool)
-> (MaxCfValue -> MaxCfValue -> Bool)
-> (MaxCfValue -> MaxCfValue -> MaxCfValue)
-> (MaxCfValue -> MaxCfValue -> MaxCfValue)
-> Ord MaxCfValue
MaxCfValue -> MaxCfValue -> Bool
MaxCfValue -> MaxCfValue -> Ordering
MaxCfValue -> MaxCfValue -> MaxCfValue
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: MaxCfValue -> MaxCfValue -> Ordering
compare :: MaxCfValue -> MaxCfValue -> Ordering
$c< :: MaxCfValue -> MaxCfValue -> Bool
< :: MaxCfValue -> MaxCfValue -> Bool
$c<= :: MaxCfValue -> MaxCfValue -> Bool
<= :: MaxCfValue -> MaxCfValue -> Bool
$c> :: MaxCfValue -> MaxCfValue -> Bool
> :: MaxCfValue -> MaxCfValue -> Bool
$c>= :: MaxCfValue -> MaxCfValue -> Bool
>= :: MaxCfValue -> MaxCfValue -> Bool
$cmax :: MaxCfValue -> MaxCfValue -> MaxCfValue
max :: MaxCfValue -> MaxCfValue -> MaxCfValue
$cmin :: MaxCfValue -> MaxCfValue -> MaxCfValue
min :: MaxCfValue -> MaxCfValue -> MaxCfValue
Ord, Int -> MaxCfValue -> ShowS
[MaxCfValue] -> ShowS
MaxCfValue -> [Char]
(Int -> MaxCfValue -> ShowS)
-> (MaxCfValue -> [Char])
-> ([MaxCfValue] -> ShowS)
-> Show MaxCfValue
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MaxCfValue -> ShowS
showsPrec :: Int -> MaxCfValue -> ShowS
$cshow :: MaxCfValue -> [Char]
show :: MaxCfValue -> [Char]
$cshowList :: [MaxCfValue] -> ShowS
showList :: [MaxCfValue] -> ShowS
Show, (forall x. MaxCfValue -> Rep MaxCfValue x)
-> (forall x. Rep MaxCfValue x -> MaxCfValue) -> Generic MaxCfValue
forall x. Rep MaxCfValue x -> MaxCfValue
forall x. MaxCfValue -> Rep MaxCfValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MaxCfValue -> Rep MaxCfValue x
from :: forall x. MaxCfValue -> Rep MaxCfValue x
$cto :: forall x. Rep MaxCfValue x -> MaxCfValue
to :: forall x. Rep MaxCfValue x -> MaxCfValue
Generic)
instance NFData MaxCfValue
data CfvType =
CfvtFormula
| CfvtMax
| CfvtMin
| CfvtNum
| CfvtPercent
| CfvtPercentile
deriving (CfvType -> CfvType -> Bool
(CfvType -> CfvType -> Bool)
-> (CfvType -> CfvType -> Bool) -> Eq CfvType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CfvType -> CfvType -> Bool
== :: CfvType -> CfvType -> Bool
$c/= :: CfvType -> CfvType -> Bool
/= :: CfvType -> CfvType -> Bool
Eq, Eq CfvType
Eq CfvType =>
(CfvType -> CfvType -> Ordering)
-> (CfvType -> CfvType -> Bool)
-> (CfvType -> CfvType -> Bool)
-> (CfvType -> CfvType -> Bool)
-> (CfvType -> CfvType -> Bool)
-> (CfvType -> CfvType -> CfvType)
-> (CfvType -> CfvType -> CfvType)
-> Ord CfvType
CfvType -> CfvType -> Bool
CfvType -> CfvType -> Ordering
CfvType -> CfvType -> CfvType
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: CfvType -> CfvType -> Ordering
compare :: CfvType -> CfvType -> Ordering
$c< :: CfvType -> CfvType -> Bool
< :: CfvType -> CfvType -> Bool
$c<= :: CfvType -> CfvType -> Bool
<= :: CfvType -> CfvType -> Bool
$c> :: CfvType -> CfvType -> Bool
> :: CfvType -> CfvType -> Bool
$c>= :: CfvType -> CfvType -> Bool
>= :: CfvType -> CfvType -> Bool
$cmax :: CfvType -> CfvType -> CfvType
max :: CfvType -> CfvType -> CfvType
$cmin :: CfvType -> CfvType -> CfvType
min :: CfvType -> CfvType -> CfvType
Ord, Int -> CfvType -> ShowS
[CfvType] -> ShowS
CfvType -> [Char]
(Int -> CfvType -> ShowS)
-> (CfvType -> [Char]) -> ([CfvType] -> ShowS) -> Show CfvType
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CfvType -> ShowS
showsPrec :: Int -> CfvType -> ShowS
$cshow :: CfvType -> [Char]
show :: CfvType -> [Char]
$cshowList :: [CfvType] -> ShowS
showList :: [CfvType] -> ShowS
Show, (forall x. CfvType -> Rep CfvType x)
-> (forall x. Rep CfvType x -> CfvType) -> Generic CfvType
forall x. Rep CfvType x -> CfvType
forall x. CfvType -> Rep CfvType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CfvType -> Rep CfvType x
from :: forall x. CfvType -> Rep CfvType x
$cto :: forall x. Rep CfvType x -> CfvType
to :: forall x. Rep CfvType x -> CfvType
Generic)
instance NFData CfvType
data IconSetOptions = IconSetOptions
{ IconSetOptions -> IconSetType
_isoIconSet :: IconSetType
, IconSetOptions -> [CfValue]
_isoValues :: [CfValue]
, IconSetOptions -> Bool
_isoReverse :: Bool
, IconSetOptions -> Bool
_isoShowValue :: Bool
} deriving (IconSetOptions -> IconSetOptions -> Bool
(IconSetOptions -> IconSetOptions -> Bool)
-> (IconSetOptions -> IconSetOptions -> Bool) -> Eq IconSetOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IconSetOptions -> IconSetOptions -> Bool
== :: IconSetOptions -> IconSetOptions -> Bool
$c/= :: IconSetOptions -> IconSetOptions -> Bool
/= :: IconSetOptions -> IconSetOptions -> Bool
Eq, Eq IconSetOptions
Eq IconSetOptions =>
(IconSetOptions -> IconSetOptions -> Ordering)
-> (IconSetOptions -> IconSetOptions -> Bool)
-> (IconSetOptions -> IconSetOptions -> Bool)
-> (IconSetOptions -> IconSetOptions -> Bool)
-> (IconSetOptions -> IconSetOptions -> Bool)
-> (IconSetOptions -> IconSetOptions -> IconSetOptions)
-> (IconSetOptions -> IconSetOptions -> IconSetOptions)
-> Ord IconSetOptions
IconSetOptions -> IconSetOptions -> Bool
IconSetOptions -> IconSetOptions -> Ordering
IconSetOptions -> IconSetOptions -> IconSetOptions
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: IconSetOptions -> IconSetOptions -> Ordering
compare :: IconSetOptions -> IconSetOptions -> Ordering
$c< :: IconSetOptions -> IconSetOptions -> Bool
< :: IconSetOptions -> IconSetOptions -> Bool
$c<= :: IconSetOptions -> IconSetOptions -> Bool
<= :: IconSetOptions -> IconSetOptions -> Bool
$c> :: IconSetOptions -> IconSetOptions -> Bool
> :: IconSetOptions -> IconSetOptions -> Bool
$c>= :: IconSetOptions -> IconSetOptions -> Bool
>= :: IconSetOptions -> IconSetOptions -> Bool
$cmax :: IconSetOptions -> IconSetOptions -> IconSetOptions
max :: IconSetOptions -> IconSetOptions -> IconSetOptions
$cmin :: IconSetOptions -> IconSetOptions -> IconSetOptions
min :: IconSetOptions -> IconSetOptions -> IconSetOptions
Ord, Int -> IconSetOptions -> ShowS
[IconSetOptions] -> ShowS
IconSetOptions -> [Char]
(Int -> IconSetOptions -> ShowS)
-> (IconSetOptions -> [Char])
-> ([IconSetOptions] -> ShowS)
-> Show IconSetOptions
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> IconSetOptions -> ShowS
showsPrec :: Int -> IconSetOptions -> ShowS
$cshow :: IconSetOptions -> [Char]
show :: IconSetOptions -> [Char]
$cshowList :: [IconSetOptions] -> ShowS
showList :: [IconSetOptions] -> ShowS
Show, (forall x. IconSetOptions -> Rep IconSetOptions x)
-> (forall x. Rep IconSetOptions x -> IconSetOptions)
-> Generic IconSetOptions
forall x. Rep IconSetOptions x -> IconSetOptions
forall x. IconSetOptions -> Rep IconSetOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. IconSetOptions -> Rep IconSetOptions x
from :: forall x. IconSetOptions -> Rep IconSetOptions x
$cto :: forall x. Rep IconSetOptions x -> IconSetOptions
to :: forall x. Rep IconSetOptions x -> IconSetOptions
Generic)
instance NFData IconSetOptions
data IconSetType =
IconSet3Arrows
| IconSet3ArrowsGray
| IconSet3Flags
| IconSet3Signs
| IconSet3Symbols
| IconSet3Symbols2
| IconSet3TrafficLights1
| IconSet3TrafficLights2
| IconSet4Arrows
| IconSet4ArrowsGray
| IconSet4Rating
| IconSet4RedToBlack
| IconSet4TrafficLights
| IconSet5Arrows
| IconSet5ArrowsGray
| IconSet5Quarters
| IconSet5Rating
deriving (IconSetType -> IconSetType -> Bool
(IconSetType -> IconSetType -> Bool)
-> (IconSetType -> IconSetType -> Bool) -> Eq IconSetType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IconSetType -> IconSetType -> Bool
== :: IconSetType -> IconSetType -> Bool
$c/= :: IconSetType -> IconSetType -> Bool
/= :: IconSetType -> IconSetType -> Bool
Eq, Eq IconSetType
Eq IconSetType =>
(IconSetType -> IconSetType -> Ordering)
-> (IconSetType -> IconSetType -> Bool)
-> (IconSetType -> IconSetType -> Bool)
-> (IconSetType -> IconSetType -> Bool)
-> (IconSetType -> IconSetType -> Bool)
-> (IconSetType -> IconSetType -> IconSetType)
-> (IconSetType -> IconSetType -> IconSetType)
-> Ord IconSetType
IconSetType -> IconSetType -> Bool
IconSetType -> IconSetType -> Ordering
IconSetType -> IconSetType -> IconSetType
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: IconSetType -> IconSetType -> Ordering
compare :: IconSetType -> IconSetType -> Ordering
$c< :: IconSetType -> IconSetType -> Bool
< :: IconSetType -> IconSetType -> Bool
$c<= :: IconSetType -> IconSetType -> Bool
<= :: IconSetType -> IconSetType -> Bool
$c> :: IconSetType -> IconSetType -> Bool
> :: IconSetType -> IconSetType -> Bool
$c>= :: IconSetType -> IconSetType -> Bool
>= :: IconSetType -> IconSetType -> Bool
$cmax :: IconSetType -> IconSetType -> IconSetType
max :: IconSetType -> IconSetType -> IconSetType
$cmin :: IconSetType -> IconSetType -> IconSetType
min :: IconSetType -> IconSetType -> IconSetType
Ord, Int -> IconSetType -> ShowS
[IconSetType] -> ShowS
IconSetType -> [Char]
(Int -> IconSetType -> ShowS)
-> (IconSetType -> [Char])
-> ([IconSetType] -> ShowS)
-> Show IconSetType
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> IconSetType -> ShowS
showsPrec :: Int -> IconSetType -> ShowS
$cshow :: IconSetType -> [Char]
show :: IconSetType -> [Char]
$cshowList :: [IconSetType] -> ShowS
showList :: [IconSetType] -> ShowS
Show, (forall x. IconSetType -> Rep IconSetType x)
-> (forall x. Rep IconSetType x -> IconSetType)
-> Generic IconSetType
forall x. Rep IconSetType x -> IconSetType
forall x. IconSetType -> Rep IconSetType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. IconSetType -> Rep IconSetType x
from :: forall x. IconSetType -> Rep IconSetType x
$cto :: forall x. Rep IconSetType x -> IconSetType
to :: forall x. Rep IconSetType x -> IconSetType
Generic)
instance NFData IconSetType
data DataBarOptions = DataBarOptions
{ DataBarOptions -> Int
_dboMaxLength :: Int
, DataBarOptions -> Int
_dboMinLength :: Int
, DataBarOptions -> Bool
_dboShowValue :: Bool
, DataBarOptions -> MinCfValue
_dboMinimum :: MinCfValue
, DataBarOptions -> MaxCfValue
_dboMaximum :: MaxCfValue
, DataBarOptions -> Color
_dboColor :: Color
} deriving (DataBarOptions -> DataBarOptions -> Bool
(DataBarOptions -> DataBarOptions -> Bool)
-> (DataBarOptions -> DataBarOptions -> Bool) -> Eq DataBarOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DataBarOptions -> DataBarOptions -> Bool
== :: DataBarOptions -> DataBarOptions -> Bool
$c/= :: DataBarOptions -> DataBarOptions -> Bool
/= :: DataBarOptions -> DataBarOptions -> Bool
Eq, Eq DataBarOptions
Eq DataBarOptions =>
(DataBarOptions -> DataBarOptions -> Ordering)
-> (DataBarOptions -> DataBarOptions -> Bool)
-> (DataBarOptions -> DataBarOptions -> Bool)
-> (DataBarOptions -> DataBarOptions -> Bool)
-> (DataBarOptions -> DataBarOptions -> Bool)
-> (DataBarOptions -> DataBarOptions -> DataBarOptions)
-> (DataBarOptions -> DataBarOptions -> DataBarOptions)
-> Ord DataBarOptions
DataBarOptions -> DataBarOptions -> Bool
DataBarOptions -> DataBarOptions -> Ordering
DataBarOptions -> DataBarOptions -> DataBarOptions
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: DataBarOptions -> DataBarOptions -> Ordering
compare :: DataBarOptions -> DataBarOptions -> Ordering
$c< :: DataBarOptions -> DataBarOptions -> Bool
< :: DataBarOptions -> DataBarOptions -> Bool
$c<= :: DataBarOptions -> DataBarOptions -> Bool
<= :: DataBarOptions -> DataBarOptions -> Bool
$c> :: DataBarOptions -> DataBarOptions -> Bool
> :: DataBarOptions -> DataBarOptions -> Bool
$c>= :: DataBarOptions -> DataBarOptions -> Bool
>= :: DataBarOptions -> DataBarOptions -> Bool
$cmax :: DataBarOptions -> DataBarOptions -> DataBarOptions
max :: DataBarOptions -> DataBarOptions -> DataBarOptions
$cmin :: DataBarOptions -> DataBarOptions -> DataBarOptions
min :: DataBarOptions -> DataBarOptions -> DataBarOptions
Ord, Int -> DataBarOptions -> ShowS
[DataBarOptions] -> ShowS
DataBarOptions -> [Char]
(Int -> DataBarOptions -> ShowS)
-> (DataBarOptions -> [Char])
-> ([DataBarOptions] -> ShowS)
-> Show DataBarOptions
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DataBarOptions -> ShowS
showsPrec :: Int -> DataBarOptions -> ShowS
$cshow :: DataBarOptions -> [Char]
show :: DataBarOptions -> [Char]
$cshowList :: [DataBarOptions] -> ShowS
showList :: [DataBarOptions] -> ShowS
Show, (forall x. DataBarOptions -> Rep DataBarOptions x)
-> (forall x. Rep DataBarOptions x -> DataBarOptions)
-> Generic DataBarOptions
forall x. Rep DataBarOptions x -> DataBarOptions
forall x. DataBarOptions -> Rep DataBarOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DataBarOptions -> Rep DataBarOptions x
from :: forall x. DataBarOptions -> Rep DataBarOptions x
$cto :: forall x. Rep DataBarOptions x -> DataBarOptions
to :: forall x. Rep DataBarOptions x -> DataBarOptions
Generic)
instance NFData DataBarOptions
defaultDboMaxLength :: Int
defaultDboMaxLength :: Int
defaultDboMaxLength = Int
90
defaultDboMinLength :: Int
defaultDboMinLength :: Int
defaultDboMinLength = Int
10
dataBarWithColor :: Color -> Condition
dataBarWithColor :: Color -> Condition
dataBarWithColor Color
c =
DataBarOptions -> Condition
DataBar
DataBarOptions
{ _dboMaxLength :: Int
_dboMaxLength = Int
defaultDboMaxLength
, _dboMinLength :: Int
_dboMinLength = Int
defaultDboMinLength
, _dboShowValue :: Bool
_dboShowValue = Bool
True
, _dboMinimum :: MinCfValue
_dboMinimum = MinCfValue
CfvMin
, _dboMaximum :: MaxCfValue
_dboMaximum = MaxCfValue
CfvMax
, _dboColor :: Color
_dboColor = Color
c
}
data CfRule = CfRule
{ CfRule -> Condition
_cfrCondition :: Condition
, CfRule -> Maybe Int
_cfrDxfId :: Maybe Int
, CfRule -> Int
_cfrPriority :: Int
, CfRule -> Maybe Bool
_cfrStopIfTrue :: Maybe Bool
} deriving (CfRule -> CfRule -> Bool
(CfRule -> CfRule -> Bool)
-> (CfRule -> CfRule -> Bool) -> Eq CfRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CfRule -> CfRule -> Bool
== :: CfRule -> CfRule -> Bool
$c/= :: CfRule -> CfRule -> Bool
/= :: CfRule -> CfRule -> Bool
Eq, Eq CfRule
Eq CfRule =>
(CfRule -> CfRule -> Ordering)
-> (CfRule -> CfRule -> Bool)
-> (CfRule -> CfRule -> Bool)
-> (CfRule -> CfRule -> Bool)
-> (CfRule -> CfRule -> Bool)
-> (CfRule -> CfRule -> CfRule)
-> (CfRule -> CfRule -> CfRule)
-> Ord CfRule
CfRule -> CfRule -> Bool
CfRule -> CfRule -> Ordering
CfRule -> CfRule -> CfRule
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: CfRule -> CfRule -> Ordering
compare :: CfRule -> CfRule -> Ordering
$c< :: CfRule -> CfRule -> Bool
< :: CfRule -> CfRule -> Bool
$c<= :: CfRule -> CfRule -> Bool
<= :: CfRule -> CfRule -> Bool
$c> :: CfRule -> CfRule -> Bool
> :: CfRule -> CfRule -> Bool
$c>= :: CfRule -> CfRule -> Bool
>= :: CfRule -> CfRule -> Bool
$cmax :: CfRule -> CfRule -> CfRule
max :: CfRule -> CfRule -> CfRule
$cmin :: CfRule -> CfRule -> CfRule
min :: CfRule -> CfRule -> CfRule
Ord, Int -> CfRule -> ShowS
[CfRule] -> ShowS
CfRule -> [Char]
(Int -> CfRule -> ShowS)
-> (CfRule -> [Char]) -> ([CfRule] -> ShowS) -> Show CfRule
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CfRule -> ShowS
showsPrec :: Int -> CfRule -> ShowS
$cshow :: CfRule -> [Char]
show :: CfRule -> [Char]
$cshowList :: [CfRule] -> ShowS
showList :: [CfRule] -> ShowS
Show, (forall x. CfRule -> Rep CfRule x)
-> (forall x. Rep CfRule x -> CfRule) -> Generic CfRule
forall x. Rep CfRule x -> CfRule
forall x. CfRule -> Rep CfRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CfRule -> Rep CfRule x
from :: forall x. CfRule -> Rep CfRule x
$cto :: forall x. Rep CfRule x -> CfRule
to :: forall x. Rep CfRule x -> CfRule
Generic)
instance NFData CfRule
instance Default IconSetOptions where
def :: IconSetOptions
def =
IconSetOptions
{ _isoIconSet :: IconSetType
_isoIconSet = IconSetType
IconSet3TrafficLights1
, _isoValues :: [CfValue]
_isoValues = [Double -> CfValue
CfPercent Double
0, Double -> CfValue
CfPercent Double
33.33, Double -> CfValue
CfPercent Double
66.67]
, _isoReverse :: Bool
_isoReverse = Bool
False
, _isoShowValue :: Bool
_isoShowValue = Bool
True
}
makeLenses ''CfRule
makeLenses ''IconSetOptions
makeLenses ''DataBarOptions
type ConditionalFormatting = [CfRule]
topCfPriority :: Int
topCfPriority :: Int
topCfPriority = Int
1
instance FromCursor CfRule where
fromCursor :: Cursor -> [CfRule]
fromCursor Cursor
cur = do
Maybe Int
_cfrDxfId <- Name -> Cursor -> [Maybe Int]
forall a. FromAttrVal a => Name -> Cursor -> [Maybe a]
maybeAttribute Name
"dxfId" Cursor
cur
Int
_cfrPriority <- Name -> Cursor -> [Int]
forall a. FromAttrVal a => Name -> Cursor -> [a]
fromAttribute Name
"priority" Cursor
cur
Maybe Bool
_cfrStopIfTrue <- Name -> Cursor -> [Maybe Bool]
forall a. FromAttrVal a => Name -> Cursor -> [Maybe a]
maybeAttribute Name
"stopIfTrue" Cursor
cur
Text
cfType <- Name -> Cursor -> [Text]
forall a. FromAttrVal a => Name -> Cursor -> [a]
fromAttribute Name
"type" Cursor
cur
Condition
_cfrCondition <- Text -> Cursor -> [Condition]
readCondition Text
cfType Cursor
cur
CfRule -> [CfRule]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return CfRule{Int
Maybe Bool
Maybe Int
Condition
_cfrCondition :: Condition
_cfrDxfId :: Maybe Int
_cfrPriority :: Int
_cfrStopIfTrue :: Maybe Bool
_cfrDxfId :: Maybe Int
_cfrPriority :: Int
_cfrStopIfTrue :: Maybe Bool
_cfrCondition :: Condition
..}
readCondition :: Text -> Cursor -> [Condition]
readCondition :: Text -> Cursor -> [Condition]
readCondition Text
"aboveAverage" Cursor
cur = do
Bool
above <- Name -> Bool -> Cursor -> [Bool]
forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
fromAttributeDef Name
"aboveAverage" Bool
True Cursor
cur
Inclusion
inclusion <- Name -> Inclusion -> Cursor -> [Inclusion]
forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
fromAttributeDef Name
"equalAverage" Inclusion
Exclusive Cursor
cur
Maybe NStdDev
nStdDev <- Name -> Cursor -> [Maybe NStdDev]
forall a. FromAttrVal a => Name -> Cursor -> [Maybe a]
maybeAttribute Name
"stdDev" Cursor
cur
if Bool
above
then Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ Inclusion -> Maybe NStdDev -> Condition
AboveAverage Inclusion
inclusion Maybe NStdDev
nStdDev
else Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ Inclusion -> Maybe NStdDev -> Condition
BelowAverage Inclusion
inclusion Maybe NStdDev
nStdDev
readCondition Text
"beginsWith" Cursor
cur = do
Text
txt <- Name -> Cursor -> [Text]
forall a. FromAttrVal a => Name -> Cursor -> [a]
fromAttribute Name
"text" Cursor
cur
Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ Text -> Condition
BeginsWith Text
txt
readCondition Text
"colorScale" Cursor
cur = do
let cfvos :: [Node]
cfvos = Cursor
cur Cursor -> (Cursor -> [Node]) -> [Node]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Name -> Axis
element (Text -> Name
n_ Text
"colorScale") Axis -> (Cursor -> [Node]) -> Cursor -> [Node]
forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Name -> Axis
element (Text -> Name
n_ Text
"cfvo") Axis -> (Cursor -> Node) -> Cursor -> [Node]
forall node a b.
(Cursor node -> [a]) -> (a -> b) -> Cursor node -> [b]
&| Cursor -> Node
forall node. Cursor node -> node
node
colors :: [Node]
colors = Cursor
cur Cursor -> (Cursor -> [Node]) -> [Node]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Name -> Axis
element (Text -> Name
n_ Text
"colorScale") Axis -> (Cursor -> [Node]) -> Cursor -> [Node]
forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Name -> Axis
element (Text -> Name
n_ Text
"color") Axis -> (Cursor -> Node) -> Cursor -> [Node]
forall node a b.
(Cursor node -> [a]) -> (a -> b) -> Cursor node -> [b]
&| Cursor -> Node
forall node. Cursor node -> node
node
case ([Node]
cfvos, [Node]
colors) of
([Node
n1, Node
n2], [Node
cn1, Node
cn2]) -> do
MinCfValue
mincfv <- Cursor -> [MinCfValue]
forall a. FromCursor a => Cursor -> [a]
fromCursor (Cursor -> [MinCfValue]) -> Cursor -> [MinCfValue]
forall a b. (a -> b) -> a -> b
$ Node -> Cursor
fromNode Node
n1
Color
minc <- Cursor -> [Color]
forall a. FromCursor a => Cursor -> [a]
fromCursor (Cursor -> [Color]) -> Cursor -> [Color]
forall a b. (a -> b) -> a -> b
$ Node -> Cursor
fromNode Node
cn1
MaxCfValue
maxcfv <- Cursor -> [MaxCfValue]
forall a. FromCursor a => Cursor -> [a]
fromCursor (Cursor -> [MaxCfValue]) -> Cursor -> [MaxCfValue]
forall a b. (a -> b) -> a -> b
$ Node -> Cursor
fromNode Node
n2
Color
maxc <- Cursor -> [Color]
forall a. FromCursor a => Cursor -> [a]
fromCursor (Cursor -> [Color]) -> Cursor -> [Color]
forall a b. (a -> b) -> a -> b
$ Node -> Cursor
fromNode Node
cn2
Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ MinCfValue -> Color -> MaxCfValue -> Color -> Condition
ColorScale2 MinCfValue
mincfv Color
minc MaxCfValue
maxcfv Color
maxc
([Node
n1, Node
n2, Node
n3], [Node
cn1, Node
cn2, Node
cn3]) -> do
MinCfValue
mincfv <- Cursor -> [MinCfValue]
forall a. FromCursor a => Cursor -> [a]
fromCursor (Cursor -> [MinCfValue]) -> Cursor -> [MinCfValue]
forall a b. (a -> b) -> a -> b
$ Node -> Cursor
fromNode Node
n1
Color
minc <- Cursor -> [Color]
forall a. FromCursor a => Cursor -> [a]
fromCursor (Cursor -> [Color]) -> Cursor -> [Color]
forall a b. (a -> b) -> a -> b
$ Node -> Cursor
fromNode Node
cn1
CfValue
midcfv <- Cursor -> [CfValue]
forall a. FromCursor a => Cursor -> [a]
fromCursor (Cursor -> [CfValue]) -> Cursor -> [CfValue]
forall a b. (a -> b) -> a -> b
$ Node -> Cursor
fromNode Node
n2
Color
midc <- Cursor -> [Color]
forall a. FromCursor a => Cursor -> [a]
fromCursor (Cursor -> [Color]) -> Cursor -> [Color]
forall a b. (a -> b) -> a -> b
$ Node -> Cursor
fromNode Node
cn2
MaxCfValue
maxcfv <- Cursor -> [MaxCfValue]
forall a. FromCursor a => Cursor -> [a]
fromCursor (Cursor -> [MaxCfValue]) -> Cursor -> [MaxCfValue]
forall a b. (a -> b) -> a -> b
$ Node -> Cursor
fromNode Node
n3
Color
maxc <- Cursor -> [Color]
forall a. FromCursor a => Cursor -> [a]
fromCursor (Cursor -> [Color]) -> Cursor -> [Color]
forall a b. (a -> b) -> a -> b
$ Node -> Cursor
fromNode Node
cn3
Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ MinCfValue
-> Color -> CfValue -> Color -> MaxCfValue -> Color -> Condition
ColorScale3 MinCfValue
mincfv Color
minc CfValue
midcfv Color
midc MaxCfValue
maxcfv Color
maxc
([Node], [Node])
_ ->
[Char] -> [Condition]
forall a. HasCallStack => [Char] -> a
error [Char]
"Malformed colorScale condition"
readCondition Text
"cellIs" Cursor
cur = do
Text
operator <- Name -> Cursor -> [Text]
forall a. FromAttrVal a => Name -> Cursor -> [a]
fromAttribute Name
"operator" Cursor
cur
let formulas :: [Formula]
formulas = Cursor
cur Cursor -> (Cursor -> [Formula]) -> [Formula]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Name -> Axis
element (Text -> Name
n_ Text
"formula") Axis -> (Cursor -> [Formula]) -> Cursor -> [Formula]
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> Cursor -> [Formula]
forall a. FromCursor a => Cursor -> [a]
fromCursor
OperatorExpression
expr <- Text -> [Formula] -> [OperatorExpression]
readOpExpression Text
operator [Formula]
formulas
Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ OperatorExpression -> Condition
CellIs OperatorExpression
expr
readCondition Text
"containsBlanks" Cursor
_ = Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return Condition
ContainsBlanks
readCondition Text
"containsErrors" Cursor
_ = Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return Condition
ContainsErrors
readCondition Text
"containsText" Cursor
cur = do
Text
txt <- Name -> Cursor -> [Text]
forall a. FromAttrVal a => Name -> Cursor -> [a]
fromAttribute Name
"text" Cursor
cur
Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ Text -> Condition
ContainsText Text
txt
readCondition Text
"dataBar" Cursor
cur = (DataBarOptions -> Condition) -> [DataBarOptions] -> [Condition]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap DataBarOptions -> Condition
DataBar ([DataBarOptions] -> [Condition])
-> [DataBarOptions] -> [Condition]
forall a b. (a -> b) -> a -> b
$ Cursor
cur Cursor -> (Cursor -> [DataBarOptions]) -> [DataBarOptions]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Name -> Axis
element (Text -> Name
n_ Text
"dataBar") Axis -> (Cursor -> [DataBarOptions]) -> Cursor -> [DataBarOptions]
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> Cursor -> [DataBarOptions]
forall a. FromCursor a => Cursor -> [a]
fromCursor
readCondition Text
"duplicateValues" Cursor
_ = Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return Condition
DuplicateValues
readCondition Text
"endsWith" Cursor
cur = do
Text
txt <- Name -> Cursor -> [Text]
forall a. FromAttrVal a => Name -> Cursor -> [a]
fromAttribute Name
"text" Cursor
cur
Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ Text -> Condition
EndsWith Text
txt
readCondition Text
"expression" Cursor
cur = do
Formula
formula <- Cursor
cur Cursor -> (Cursor -> [Formula]) -> [Formula]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Name -> Axis
element (Text -> Name
n_ Text
"formula") Axis -> (Cursor -> [Formula]) -> Cursor -> [Formula]
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> Cursor -> [Formula]
forall a. FromCursor a => Cursor -> [a]
fromCursor
Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ Formula -> Condition
Expression Formula
formula
readCondition Text
"iconSet" Cursor
cur = (IconSetOptions -> Condition) -> [IconSetOptions] -> [Condition]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap IconSetOptions -> Condition
IconSet ([IconSetOptions] -> [Condition])
-> [IconSetOptions] -> [Condition]
forall a b. (a -> b) -> a -> b
$ Cursor
cur Cursor -> (Cursor -> [IconSetOptions]) -> [IconSetOptions]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Name -> Axis
element (Text -> Name
n_ Text
"iconSet") Axis -> (Cursor -> [IconSetOptions]) -> Cursor -> [IconSetOptions]
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> Cursor -> [IconSetOptions]
forall a. FromCursor a => Cursor -> [a]
fromCursor
readCondition Text
"notContainsBlanks" Cursor
_ = Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return Condition
DoesNotContainBlanks
readCondition Text
"notContainsErrors" Cursor
_ = Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return Condition
DoesNotContainErrors
readCondition Text
"notContainsText" Cursor
cur = do
Text
txt <- Name -> Cursor -> [Text]
forall a. FromAttrVal a => Name -> Cursor -> [a]
fromAttribute Name
"text" Cursor
cur
Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ Text -> Condition
DoesNotContainText Text
txt
readCondition Text
"timePeriod" Cursor
cur = do
TimePeriod
period <- Name -> Cursor -> [TimePeriod]
forall a. FromAttrVal a => Name -> Cursor -> [a]
fromAttribute Name
"timePeriod" Cursor
cur
Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ TimePeriod -> Condition
InTimePeriod TimePeriod
period
readCondition Text
"top10" Cursor
cur = do
Bool
bottom <- Name -> Bool -> Cursor -> [Bool]
forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
fromAttributeDef Name
"bottom" Bool
False Cursor
cur
Bool
percent <- Name -> Bool -> Cursor -> [Bool]
forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
fromAttributeDef Name
"percent" Bool
False Cursor
cur
Int
rank <- Name -> Cursor -> [Int]
forall a. FromAttrVal a => Name -> Cursor -> [a]
fromAttribute Name
"rank" Cursor
cur
case (Bool
bottom, Bool
percent) of
(Bool
True, Bool
True) -> Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ Int -> Condition
BottomNPercent Int
rank
(Bool
True, Bool
False) -> Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ Int -> Condition
BottomNValues Int
rank
(Bool
False, Bool
True) -> Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ Int -> Condition
TopNPercent Int
rank
(Bool
False, Bool
False) -> Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> [Condition]) -> Condition -> [Condition]
forall a b. (a -> b) -> a -> b
$ Int -> Condition
TopNValues Int
rank
readCondition Text
"uniqueValues" Cursor
_ = Condition -> [Condition]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return Condition
UniqueValues
readCondition Text
t Cursor
_ = [Char] -> [Condition]
forall a. HasCallStack => [Char] -> a
error ([Char] -> [Condition]) -> [Char] -> [Condition]
forall a b. (a -> b) -> a -> b
$ [Char]
"Unexpected conditional formatting type " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> [Char]
forall a. Show a => a -> [Char]
show Text
t
readOpExpression :: Text -> [Formula] -> [OperatorExpression]
readOpExpression :: Text -> [Formula] -> [OperatorExpression]
readOpExpression Text
"beginsWith" [Formula
f] = [Formula -> OperatorExpression
OpBeginsWith Formula
f ]
readOpExpression Text
"between" [Formula
f1, Formula
f2] = [Formula -> Formula -> OperatorExpression
OpBetween Formula
f1 Formula
f2]
readOpExpression Text
"containsText" [Formula
f] = [Formula -> OperatorExpression
OpContainsText Formula
f]
readOpExpression Text
"endsWith" [Formula
f] = [Formula -> OperatorExpression
OpEndsWith Formula
f]
readOpExpression Text
"equal" [Formula
f] = [Formula -> OperatorExpression
OpEqual Formula
f]
readOpExpression Text
"greaterThan" [Formula
f] = [Formula -> OperatorExpression
OpGreaterThan Formula
f]
readOpExpression Text
"greaterThanOrEqual" [Formula
f] = [Formula -> OperatorExpression
OpGreaterThanOrEqual Formula
f]
readOpExpression Text
"lessThan" [Formula
f] = [Formula -> OperatorExpression
OpLessThan Formula
f]
readOpExpression Text
"lessThanOrEqual" [Formula
f] = [Formula -> OperatorExpression
OpLessThanOrEqual Formula
f]
readOpExpression Text
"notBetween" [Formula
f1, Formula
f2] = [Formula -> Formula -> OperatorExpression
OpNotBetween Formula
f1 Formula
f2]
readOpExpression Text
"notContains" [Formula
f] = [Formula -> OperatorExpression
OpNotContains Formula
f]
readOpExpression Text
"notEqual" [Formula
f] = [Formula -> OperatorExpression
OpNotEqual Formula
f]
readOpExpression Text
_ [Formula]
_ = []
instance FromXenoNode CfRule where
fromXenoNode :: Node -> Either Text CfRule
fromXenoNode Node
root = Node -> AttrParser CfRule -> Either Text CfRule
forall a. Node -> AttrParser a -> Either Text a
parseAttributes Node
root (AttrParser CfRule -> Either Text CfRule)
-> AttrParser CfRule -> Either Text CfRule
forall a b. (a -> b) -> a -> b
$ do
Maybe Int
_cfrDxfId <- ByteString -> AttrParser (Maybe Int)
forall a. FromAttrBs a => ByteString -> AttrParser (Maybe a)
maybeAttr ByteString
"dxfId"
Int
_cfrPriority <- ByteString -> AttrParser Int
forall a. FromAttrBs a => ByteString -> AttrParser a
fromAttr ByteString
"priority"
Maybe Bool
_cfrStopIfTrue <- ByteString -> AttrParser (Maybe Bool)
forall a. FromAttrBs a => ByteString -> AttrParser (Maybe a)
maybeAttr ByteString
"stopIfTrue"
ByteString
cfType <- ByteString -> AttrParser ByteString
forall a. FromAttrBs a => ByteString -> AttrParser a
fromAttr ByteString
"type"
Condition
_cfrCondition <- ByteString -> AttrParser Condition
readConditionX ByteString
cfType
CfRule -> AttrParser CfRule
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return CfRule {Int
Maybe Bool
Maybe Int
Condition
_cfrCondition :: Condition
_cfrDxfId :: Maybe Int
_cfrPriority :: Int
_cfrStopIfTrue :: Maybe Bool
_cfrDxfId :: Maybe Int
_cfrPriority :: Int
_cfrStopIfTrue :: Maybe Bool
_cfrCondition :: Condition
..}
where
readConditionX :: ByteString -> AttrParser Condition
readConditionX (ByteString
"aboveAverage" :: ByteString) = do
Bool
above <- ByteString -> Bool -> AttrParser Bool
forall a. FromAttrBs a => ByteString -> a -> AttrParser a
fromAttrDef ByteString
"aboveAverage" Bool
True
Inclusion
inclusion <- ByteString -> Inclusion -> AttrParser Inclusion
forall a. FromAttrBs a => ByteString -> a -> AttrParser a
fromAttrDef ByteString
"equalAverage" Inclusion
Exclusive
Maybe NStdDev
nStdDev <- ByteString -> AttrParser (Maybe NStdDev)
forall a. FromAttrBs a => ByteString -> AttrParser (Maybe a)
maybeAttr ByteString
"stdDev"
if Bool
above
then Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> Condition -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Inclusion -> Maybe NStdDev -> Condition
AboveAverage Inclusion
inclusion Maybe NStdDev
nStdDev
else Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> Condition -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Inclusion -> Maybe NStdDev -> Condition
BelowAverage Inclusion
inclusion Maybe NStdDev
nStdDev
readConditionX ByteString
"beginsWith" = Text -> Condition
BeginsWith (Text -> Condition) -> AttrParser Text -> AttrParser Condition
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> AttrParser Text
forall a. FromAttrBs a => ByteString -> AttrParser a
fromAttr ByteString
"text"
readConditionX ByteString
"colorScale" = Either Text Condition -> AttrParser Condition
forall a. Either Text a -> AttrParser a
toAttrParser (Either Text Condition -> AttrParser Condition)
-> Either Text Condition -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ do
Maybe ([Node], [Node])
xs <- Node
-> ChildCollector (Maybe ([Node], [Node]))
-> Either Text (Maybe ([Node], [Node]))
forall a. Node -> ChildCollector a -> Either Text a
collectChildren Node
root (ChildCollector (Maybe ([Node], [Node]))
-> Either Text (Maybe ([Node], [Node])))
-> ((Node -> Either Text ([Node], [Node]))
-> ChildCollector (Maybe ([Node], [Node])))
-> (Node -> Either Text ([Node], [Node]))
-> Either Text (Maybe ([Node], [Node]))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString
-> (Node -> Either Text ([Node], [Node]))
-> ChildCollector (Maybe ([Node], [Node]))
forall a.
ByteString -> (Node -> Either Text a) -> ChildCollector (Maybe a)
maybeParse ByteString
"colorScale" ((Node -> Either Text ([Node], [Node]))
-> Either Text (Maybe ([Node], [Node])))
-> (Node -> Either Text ([Node], [Node]))
-> Either Text (Maybe ([Node], [Node]))
forall a b. (a -> b) -> a -> b
$ \Node
node ->
Node
-> ChildCollector ([Node], [Node]) -> Either Text ([Node], [Node])
forall a. Node -> ChildCollector a -> Either Text a
collectChildren Node
node (ChildCollector ([Node], [Node]) -> Either Text ([Node], [Node]))
-> ChildCollector ([Node], [Node]) -> Either Text ([Node], [Node])
forall a b. (a -> b) -> a -> b
$ (,) ([Node] -> [Node] -> ([Node], [Node]))
-> ChildCollector [Node]
-> ChildCollector ([Node] -> ([Node], [Node]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> ChildCollector [Node]
childList ByteString
"cfvo"
ChildCollector ([Node] -> ([Node], [Node]))
-> ChildCollector [Node] -> ChildCollector ([Node], [Node])
forall a b.
ChildCollector (a -> b) -> ChildCollector a -> ChildCollector b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ByteString -> ChildCollector [Node]
childList ByteString
"color"
case Maybe ([Node], [Node])
xs of
Just ([Node
n1, Node
n2], [Node
cn1, Node
cn2]) -> do
MinCfValue
mincfv <- Node -> Either Text MinCfValue
forall a. FromXenoNode a => Node -> Either Text a
fromXenoNode Node
n1
Color
minc <- Node -> Either Text Color
forall a. FromXenoNode a => Node -> Either Text a
fromXenoNode Node
cn1
MaxCfValue
maxcfv <- Node -> Either Text MaxCfValue
forall a. FromXenoNode a => Node -> Either Text a
fromXenoNode Node
n2
Color
maxc <- Node -> Either Text Color
forall a. FromXenoNode a => Node -> Either Text a
fromXenoNode Node
cn2
Condition -> Either Text Condition
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> Either Text Condition)
-> Condition -> Either Text Condition
forall a b. (a -> b) -> a -> b
$ MinCfValue -> Color -> MaxCfValue -> Color -> Condition
ColorScale2 MinCfValue
mincfv Color
minc MaxCfValue
maxcfv Color
maxc
Just ([Node
n1, Node
n2, Node
n3], [Node
cn1, Node
cn2, Node
cn3]) -> do
MinCfValue
mincfv <- Node -> Either Text MinCfValue
forall a. FromXenoNode a => Node -> Either Text a
fromXenoNode Node
n1
Color
minc <- Node -> Either Text Color
forall a. FromXenoNode a => Node -> Either Text a
fromXenoNode Node
cn1
CfValue
midcfv <- Node -> Either Text CfValue
forall a. FromXenoNode a => Node -> Either Text a
fromXenoNode Node
n2
Color
midc <- Node -> Either Text Color
forall a. FromXenoNode a => Node -> Either Text a
fromXenoNode Node
cn2
MaxCfValue
maxcfv <- Node -> Either Text MaxCfValue
forall a. FromXenoNode a => Node -> Either Text a
fromXenoNode Node
n3
Color
maxc <- Node -> Either Text Color
forall a. FromXenoNode a => Node -> Either Text a
fromXenoNode Node
cn3
Condition -> Either Text Condition
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> Either Text Condition)
-> Condition -> Either Text Condition
forall a b. (a -> b) -> a -> b
$ MinCfValue
-> Color -> CfValue -> Color -> MaxCfValue -> Color -> Condition
ColorScale3 MinCfValue
mincfv Color
minc CfValue
midcfv Color
midc MaxCfValue
maxcfv Color
maxc
Maybe ([Node], [Node])
_ ->
Text -> Either Text Condition
forall a b. a -> Either a b
Left Text
"Malformed colorScale condition"
readConditionX ByteString
"cellIs" = do
ByteString
operator <- ByteString -> AttrParser ByteString
forall a. FromAttrBs a => ByteString -> AttrParser a
fromAttr ByteString
"operator"
[Formula]
formulas <- Either Text [Formula] -> AttrParser [Formula]
forall a. Either Text a -> AttrParser a
toAttrParser (Either Text [Formula] -> AttrParser [Formula])
-> (ChildCollector [Formula] -> Either Text [Formula])
-> ChildCollector [Formula]
-> AttrParser [Formula]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Node -> ChildCollector [Formula] -> Either Text [Formula]
forall a. Node -> ChildCollector a -> Either Text a
collectChildren Node
root (ChildCollector [Formula] -> AttrParser [Formula])
-> ChildCollector [Formula] -> AttrParser [Formula]
forall a b. (a -> b) -> a -> b
$ ByteString -> ChildCollector [Formula]
forall a. FromXenoNode a => ByteString -> ChildCollector [a]
fromChildList ByteString
"formula"
case (ByteString
operator, [Formula]
formulas) of
(ByteString
"beginsWith" :: ByteString, [Formula
f]) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> (OperatorExpression -> Condition)
-> OperatorExpression
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OperatorExpression -> Condition
CellIs (OperatorExpression -> AttrParser Condition)
-> OperatorExpression -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Formula -> OperatorExpression
OpBeginsWith Formula
f
(ByteString
"between", [Formula
f1, Formula
f2]) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> (OperatorExpression -> Condition)
-> OperatorExpression
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OperatorExpression -> Condition
CellIs (OperatorExpression -> AttrParser Condition)
-> OperatorExpression -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Formula -> Formula -> OperatorExpression
OpBetween Formula
f1 Formula
f2
(ByteString
"containsText", [Formula
f]) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> (OperatorExpression -> Condition)
-> OperatorExpression
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OperatorExpression -> Condition
CellIs (OperatorExpression -> AttrParser Condition)
-> OperatorExpression -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Formula -> OperatorExpression
OpContainsText Formula
f
(ByteString
"endsWith", [Formula
f]) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> (OperatorExpression -> Condition)
-> OperatorExpression
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OperatorExpression -> Condition
CellIs (OperatorExpression -> AttrParser Condition)
-> OperatorExpression -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Formula -> OperatorExpression
OpEndsWith Formula
f
(ByteString
"equal", [Formula
f]) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> (OperatorExpression -> Condition)
-> OperatorExpression
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OperatorExpression -> Condition
CellIs (OperatorExpression -> AttrParser Condition)
-> OperatorExpression -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Formula -> OperatorExpression
OpEqual Formula
f
(ByteString
"greaterThan", [Formula
f]) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> (OperatorExpression -> Condition)
-> OperatorExpression
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OperatorExpression -> Condition
CellIs (OperatorExpression -> AttrParser Condition)
-> OperatorExpression -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Formula -> OperatorExpression
OpGreaterThan Formula
f
(ByteString
"greaterThanOrEqual", [Formula
f]) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> (OperatorExpression -> Condition)
-> OperatorExpression
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OperatorExpression -> Condition
CellIs (OperatorExpression -> AttrParser Condition)
-> OperatorExpression -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Formula -> OperatorExpression
OpGreaterThanOrEqual Formula
f
(ByteString
"lessThan", [Formula
f]) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> (OperatorExpression -> Condition)
-> OperatorExpression
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OperatorExpression -> Condition
CellIs (OperatorExpression -> AttrParser Condition)
-> OperatorExpression -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Formula -> OperatorExpression
OpLessThan Formula
f
(ByteString
"lessThanOrEqual", [Formula
f]) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> (OperatorExpression -> Condition)
-> OperatorExpression
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OperatorExpression -> Condition
CellIs (OperatorExpression -> AttrParser Condition)
-> OperatorExpression -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Formula -> OperatorExpression
OpLessThanOrEqual Formula
f
(ByteString
"notBetween", [Formula
f1, Formula
f2]) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> (OperatorExpression -> Condition)
-> OperatorExpression
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OperatorExpression -> Condition
CellIs (OperatorExpression -> AttrParser Condition)
-> OperatorExpression -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Formula -> Formula -> OperatorExpression
OpNotBetween Formula
f1 Formula
f2
(ByteString
"notContains", [Formula
f]) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> (OperatorExpression -> Condition)
-> OperatorExpression
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OperatorExpression -> Condition
CellIs (OperatorExpression -> AttrParser Condition)
-> OperatorExpression -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Formula -> OperatorExpression
OpNotContains Formula
f
(ByteString
"notEqual", [Formula
f]) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> (OperatorExpression -> Condition)
-> OperatorExpression
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OperatorExpression -> Condition
CellIs (OperatorExpression -> AttrParser Condition)
-> OperatorExpression -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Formula -> OperatorExpression
OpNotEqual Formula
f
(ByteString, [Formula])
_ -> Either Text Condition -> AttrParser Condition
forall a. Either Text a -> AttrParser a
toAttrParser (Either Text Condition -> AttrParser Condition)
-> Either Text Condition -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Text -> Either Text Condition
forall a b. a -> Either a b
Left Text
"Bad cellIs rule"
readConditionX ByteString
"containsBlanks" = Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return Condition
ContainsBlanks
readConditionX ByteString
"containsErrors" = Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return Condition
ContainsErrors
readConditionX ByteString
"containsText" = Text -> Condition
ContainsText (Text -> Condition) -> AttrParser Text -> AttrParser Condition
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> AttrParser Text
forall a. FromAttrBs a => ByteString -> AttrParser a
fromAttr ByteString
"text"
readConditionX ByteString
"dataBar" =
(DataBarOptions -> Condition)
-> AttrParser DataBarOptions -> AttrParser Condition
forall a b. (a -> b) -> AttrParser a -> AttrParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap DataBarOptions -> Condition
DataBar (AttrParser DataBarOptions -> AttrParser Condition)
-> (ChildCollector DataBarOptions -> AttrParser DataBarOptions)
-> ChildCollector DataBarOptions
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either Text DataBarOptions -> AttrParser DataBarOptions
forall a. Either Text a -> AttrParser a
toAttrParser (Either Text DataBarOptions -> AttrParser DataBarOptions)
-> (ChildCollector DataBarOptions -> Either Text DataBarOptions)
-> ChildCollector DataBarOptions
-> AttrParser DataBarOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Node -> ChildCollector DataBarOptions -> Either Text DataBarOptions
forall a. Node -> ChildCollector a -> Either Text a
collectChildren Node
root (ChildCollector DataBarOptions -> AttrParser Condition)
-> ChildCollector DataBarOptions -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ ByteString -> ChildCollector DataBarOptions
forall a. FromXenoNode a => ByteString -> ChildCollector a
fromChild ByteString
"dataBar"
readConditionX ByteString
"duplicateValues" = Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return Condition
DuplicateValues
readConditionX ByteString
"endsWith" = Text -> Condition
EndsWith (Text -> Condition) -> AttrParser Text -> AttrParser Condition
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> AttrParser Text
forall a. FromAttrBs a => ByteString -> AttrParser a
fromAttr ByteString
"text"
readConditionX ByteString
"expression" =
(Formula -> Condition)
-> AttrParser Formula -> AttrParser Condition
forall a b. (a -> b) -> AttrParser a -> AttrParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Formula -> Condition
Expression (AttrParser Formula -> AttrParser Condition)
-> (ChildCollector Formula -> AttrParser Formula)
-> ChildCollector Formula
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either Text Formula -> AttrParser Formula
forall a. Either Text a -> AttrParser a
toAttrParser (Either Text Formula -> AttrParser Formula)
-> (ChildCollector Formula -> Either Text Formula)
-> ChildCollector Formula
-> AttrParser Formula
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Node -> ChildCollector Formula -> Either Text Formula
forall a. Node -> ChildCollector a -> Either Text a
collectChildren Node
root (ChildCollector Formula -> AttrParser Condition)
-> ChildCollector Formula -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ ByteString -> ChildCollector Formula
forall a. FromXenoNode a => ByteString -> ChildCollector a
fromChild ByteString
"formula"
readConditionX ByteString
"iconSet" =
(IconSetOptions -> Condition)
-> AttrParser IconSetOptions -> AttrParser Condition
forall a b. (a -> b) -> AttrParser a -> AttrParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap IconSetOptions -> Condition
IconSet (AttrParser IconSetOptions -> AttrParser Condition)
-> (ChildCollector IconSetOptions -> AttrParser IconSetOptions)
-> ChildCollector IconSetOptions
-> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either Text IconSetOptions -> AttrParser IconSetOptions
forall a. Either Text a -> AttrParser a
toAttrParser (Either Text IconSetOptions -> AttrParser IconSetOptions)
-> (ChildCollector IconSetOptions -> Either Text IconSetOptions)
-> ChildCollector IconSetOptions
-> AttrParser IconSetOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Node -> ChildCollector IconSetOptions -> Either Text IconSetOptions
forall a. Node -> ChildCollector a -> Either Text a
collectChildren Node
root (ChildCollector IconSetOptions -> AttrParser Condition)
-> ChildCollector IconSetOptions -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ ByteString -> ChildCollector IconSetOptions
forall a. FromXenoNode a => ByteString -> ChildCollector a
fromChild ByteString
"iconSet"
readConditionX ByteString
"notContainsBlanks" = Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return Condition
DoesNotContainBlanks
readConditionX ByteString
"notContainsErrors" = Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return Condition
DoesNotContainErrors
readConditionX ByteString
"notContainsText" =
Text -> Condition
DoesNotContainText (Text -> Condition) -> AttrParser Text -> AttrParser Condition
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> AttrParser Text
forall a. FromAttrBs a => ByteString -> AttrParser a
fromAttr ByteString
"text"
readConditionX ByteString
"timePeriod" = TimePeriod -> Condition
InTimePeriod (TimePeriod -> Condition)
-> AttrParser TimePeriod -> AttrParser Condition
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> AttrParser TimePeriod
forall a. FromAttrBs a => ByteString -> AttrParser a
fromAttr ByteString
"timePeriod"
readConditionX ByteString
"top10" = do
Bool
bottom <- ByteString -> Bool -> AttrParser Bool
forall a. FromAttrBs a => ByteString -> a -> AttrParser a
fromAttrDef ByteString
"bottom" Bool
False
Bool
percent <- ByteString -> Bool -> AttrParser Bool
forall a. FromAttrBs a => ByteString -> a -> AttrParser a
fromAttrDef ByteString
"percent" Bool
False
Int
rank <- ByteString -> AttrParser Int
forall a. FromAttrBs a => ByteString -> AttrParser a
fromAttr ByteString
"rank"
case (Bool
bottom, Bool
percent) of
(Bool
True, Bool
True) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> Condition -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Int -> Condition
BottomNPercent Int
rank
(Bool
True, Bool
False) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> Condition -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Int -> Condition
BottomNValues Int
rank
(Bool
False, Bool
True) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> Condition -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Int -> Condition
TopNPercent Int
rank
(Bool
False, Bool
False) -> Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Condition -> AttrParser Condition)
-> Condition -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Int -> Condition
TopNValues Int
rank
readConditionX ByteString
"uniqueValues" = Condition -> AttrParser Condition
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return Condition
UniqueValues
readConditionX ByteString
x =
Either Text Condition -> AttrParser Condition
forall a. Either Text a -> AttrParser a
toAttrParser (Either Text Condition -> AttrParser Condition)
-> (Text -> Either Text Condition) -> Text -> AttrParser Condition
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Either Text Condition
forall a b. a -> Either a b
Left (Text -> AttrParser Condition) -> Text -> AttrParser Condition
forall a b. (a -> b) -> a -> b
$ Text
"Unexpected conditional formatting type " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
T.pack (ByteString -> [Char]
forall a. Show a => a -> [Char]
show ByteString
x)
instance FromAttrVal TimePeriod where
fromAttrVal :: Reader TimePeriod
fromAttrVal Text
"last7Days" = TimePeriod -> Either [Char] (TimePeriod, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess TimePeriod
PerLast7Days
fromAttrVal Text
"lastMonth" = TimePeriod -> Either [Char] (TimePeriod, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess TimePeriod
PerLastMonth
fromAttrVal Text
"lastWeek" = TimePeriod -> Either [Char] (TimePeriod, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess TimePeriod
PerLastWeek
fromAttrVal Text
"nextMonth" = TimePeriod -> Either [Char] (TimePeriod, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess TimePeriod
PerNextMonth
fromAttrVal Text
"nextWeek" = TimePeriod -> Either [Char] (TimePeriod, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess TimePeriod
PerNextWeek
fromAttrVal Text
"thisMonth" = TimePeriod -> Either [Char] (TimePeriod, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess TimePeriod
PerThisMonth
fromAttrVal Text
"thisWeek" = TimePeriod -> Either [Char] (TimePeriod, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess TimePeriod
PerThisWeek
fromAttrVal Text
"today" = TimePeriod -> Either [Char] (TimePeriod, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess TimePeriod
PerToday
fromAttrVal Text
"tomorrow" = TimePeriod -> Either [Char] (TimePeriod, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess TimePeriod
PerTomorrow
fromAttrVal Text
"yesterday" = TimePeriod -> Either [Char] (TimePeriod, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess TimePeriod
PerYesterday
fromAttrVal Text
t = Text -> Reader TimePeriod
forall a. Text -> Text -> Either [Char] (a, Text)
invalidText Text
"TimePeriod" Text
t
instance FromAttrBs TimePeriod where
fromAttrBs :: ByteString -> Either Text TimePeriod
fromAttrBs ByteString
"last7Days" = TimePeriod -> Either Text TimePeriod
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return TimePeriod
PerLast7Days
fromAttrBs ByteString
"lastMonth" = TimePeriod -> Either Text TimePeriod
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return TimePeriod
PerLastMonth
fromAttrBs ByteString
"lastWeek" = TimePeriod -> Either Text TimePeriod
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return TimePeriod
PerLastWeek
fromAttrBs ByteString
"nextMonth" = TimePeriod -> Either Text TimePeriod
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return TimePeriod
PerNextMonth
fromAttrBs ByteString
"nextWeek" = TimePeriod -> Either Text TimePeriod
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return TimePeriod
PerNextWeek
fromAttrBs ByteString
"thisMonth" = TimePeriod -> Either Text TimePeriod
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return TimePeriod
PerThisMonth
fromAttrBs ByteString
"thisWeek" = TimePeriod -> Either Text TimePeriod
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return TimePeriod
PerThisWeek
fromAttrBs ByteString
"today" = TimePeriod -> Either Text TimePeriod
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return TimePeriod
PerToday
fromAttrBs ByteString
"tomorrow" = TimePeriod -> Either Text TimePeriod
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return TimePeriod
PerTomorrow
fromAttrBs ByteString
"yesterday" = TimePeriod -> Either Text TimePeriod
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return TimePeriod
PerYesterday
fromAttrBs ByteString
x = Text -> ByteString -> Either Text TimePeriod
forall a. Text -> ByteString -> Either Text a
unexpectedAttrBs Text
"TimePeriod" ByteString
x
instance FromAttrVal CfvType where
fromAttrVal :: Reader CfvType
fromAttrVal Text
"num" = CfvType -> Either [Char] (CfvType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess CfvType
CfvtNum
fromAttrVal Text
"percent" = CfvType -> Either [Char] (CfvType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess CfvType
CfvtPercent
fromAttrVal Text
"max" = CfvType -> Either [Char] (CfvType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess CfvType
CfvtMax
fromAttrVal Text
"min" = CfvType -> Either [Char] (CfvType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess CfvType
CfvtMin
fromAttrVal Text
"formula" = CfvType -> Either [Char] (CfvType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess CfvType
CfvtFormula
fromAttrVal Text
"percentile" = CfvType -> Either [Char] (CfvType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess CfvType
CfvtPercentile
fromAttrVal Text
t = Text -> Reader CfvType
forall a. Text -> Text -> Either [Char] (a, Text)
invalidText Text
"CfvType" Text
t
instance FromAttrBs CfvType where
fromAttrBs :: ByteString -> Either Text CfvType
fromAttrBs ByteString
"num" = CfvType -> Either Text CfvType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return CfvType
CfvtNum
fromAttrBs ByteString
"percent" = CfvType -> Either Text CfvType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return CfvType
CfvtPercent
fromAttrBs ByteString
"max" = CfvType -> Either Text CfvType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return CfvType
CfvtMax
fromAttrBs ByteString
"min" = CfvType -> Either Text CfvType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return CfvType
CfvtMin
fromAttrBs ByteString
"formula" = CfvType -> Either Text CfvType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return CfvType
CfvtFormula
fromAttrBs ByteString
"percentile" = CfvType -> Either Text CfvType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return CfvType
CfvtPercentile
fromAttrBs ByteString
x = Text -> ByteString -> Either Text CfvType
forall a. Text -> ByteString -> Either Text a
unexpectedAttrBs Text
"CfvType" ByteString
x
readCfValue :: (CfValue -> a) -> [a] -> [a] -> Cursor -> [a]
readCfValue :: forall a. (CfValue -> a) -> [a] -> [a] -> Cursor -> [a]
readCfValue CfValue -> a
f [a]
minVal [a]
maxVal Cursor
c = do
CfvType
vType <- Name -> Cursor -> [CfvType]
forall a. FromAttrVal a => Name -> Cursor -> [a]
fromAttribute Name
"type" Cursor
c
case CfvType
vType of
CfvType
CfvtNum -> do
Double
v <- Name -> Cursor -> [Double]
forall a. FromAttrVal a => Name -> Cursor -> [a]
fromAttribute Name
"val" Cursor
c
a -> [a]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> [a]) -> (CfValue -> a) -> CfValue -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CfValue -> a
f (CfValue -> [a]) -> CfValue -> [a]
forall a b. (a -> b) -> a -> b
$ Double -> CfValue
CfValue Double
v
CfvType
CfvtFormula -> do
Formula
v <- Name -> Cursor -> [Formula]
forall a. FromAttrVal a => Name -> Cursor -> [a]
fromAttribute Name
"val" Cursor
c
a -> [a]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> [a]) -> (CfValue -> a) -> CfValue -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CfValue -> a
f (CfValue -> [a]) -> CfValue -> [a]
forall a b. (a -> b) -> a -> b
$ Formula -> CfValue
CfFormula Formula
v
CfvType
CfvtPercent -> do
Double
v <- Name -> Cursor -> [Double]
forall a. FromAttrVal a => Name -> Cursor -> [a]
fromAttribute Name
"val" Cursor
c
a -> [a]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> [a]) -> (CfValue -> a) -> CfValue -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CfValue -> a
f (CfValue -> [a]) -> CfValue -> [a]
forall a b. (a -> b) -> a -> b
$ Double -> CfValue
CfPercent Double
v
CfvType
CfvtPercentile -> do
Double
v <- Name -> Cursor -> [Double]
forall a. FromAttrVal a => Name -> Cursor -> [a]
fromAttribute Name
"val" Cursor
c
a -> [a]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> [a]) -> (CfValue -> a) -> CfValue -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CfValue -> a
f (CfValue -> [a]) -> CfValue -> [a]
forall a b. (a -> b) -> a -> b
$ Double -> CfValue
CfPercentile Double
v
CfvType
CfvtMin -> [a]
minVal
CfvType
CfvtMax -> [a]
maxVal
readCfValueX ::
(CfValue -> a)
-> Either Text a
-> Either Text a
-> Xeno.Node
-> Either Text a
readCfValueX :: forall a.
(CfValue -> a)
-> Either Text a -> Either Text a -> Node -> Either Text a
readCfValueX CfValue -> a
f Either Text a
minVal Either Text a
maxVal Node
root =
Node -> AttrParser a -> Either Text a
forall a. Node -> AttrParser a -> Either Text a
parseAttributes Node
root (AttrParser a -> Either Text a) -> AttrParser a -> Either Text a
forall a b. (a -> b) -> a -> b
$ do
CfvType
vType <- ByteString -> AttrParser CfvType
forall a. FromAttrBs a => ByteString -> AttrParser a
fromAttr ByteString
"type"
case CfvType
vType of
CfvType
CfvtNum -> do
Double
v <- ByteString -> AttrParser Double
forall a. FromAttrBs a => ByteString -> AttrParser a
fromAttr ByteString
"val"
a -> AttrParser a
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> AttrParser a) -> (CfValue -> a) -> CfValue -> AttrParser a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CfValue -> a
f (CfValue -> AttrParser a) -> CfValue -> AttrParser a
forall a b. (a -> b) -> a -> b
$ Double -> CfValue
CfValue Double
v
CfvType
CfvtFormula -> do
Formula
v <- ByteString -> AttrParser Formula
forall a. FromAttrBs a => ByteString -> AttrParser a
fromAttr ByteString
"val"
a -> AttrParser a
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> AttrParser a) -> (CfValue -> a) -> CfValue -> AttrParser a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CfValue -> a
f (CfValue -> AttrParser a) -> CfValue -> AttrParser a
forall a b. (a -> b) -> a -> b
$ Formula -> CfValue
CfFormula Formula
v
CfvType
CfvtPercent -> do
Double
v <- ByteString -> AttrParser Double
forall a. FromAttrBs a => ByteString -> AttrParser a
fromAttr ByteString
"val"
a -> AttrParser a
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> AttrParser a) -> (CfValue -> a) -> CfValue -> AttrParser a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CfValue -> a
f (CfValue -> AttrParser a) -> CfValue -> AttrParser a
forall a b. (a -> b) -> a -> b
$ Double -> CfValue
CfPercent Double
v
CfvType
CfvtPercentile -> do
Double
v <- ByteString -> AttrParser Double
forall a. FromAttrBs a => ByteString -> AttrParser a
fromAttr ByteString
"val"
a -> AttrParser a
forall a. a -> AttrParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> AttrParser a) -> (CfValue -> a) -> CfValue -> AttrParser a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CfValue -> a
f (CfValue -> AttrParser a) -> CfValue -> AttrParser a
forall a b. (a -> b) -> a -> b
$ Double -> CfValue
CfPercentile Double
v
CfvType
CfvtMin -> Either Text a -> AttrParser a
forall a. Either Text a -> AttrParser a
toAttrParser Either Text a
minVal
CfvType
CfvtMax -> Either Text a -> AttrParser a
forall a. Either Text a -> AttrParser a
toAttrParser Either Text a
maxVal
failMinCfvType :: [a]
failMinCfvType :: forall a. [a]
failMinCfvType = [Char] -> [a]
forall a. [Char] -> [a]
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
"unexpected 'min' type"
failMinCfvTypeX :: Either Text a
failMinCfvTypeX :: forall a. Either Text a
failMinCfvTypeX = Text -> Either Text a
forall a b. a -> Either a b
Left Text
"unexpected 'min' type"
failMaxCfvType :: [a]
failMaxCfvType :: forall a. [a]
failMaxCfvType = [Char] -> [a]
forall a. [Char] -> [a]
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
"unexpected 'max' type"
failMaxCfvTypeX :: Either Text a
failMaxCfvTypeX :: forall a. Either Text a
failMaxCfvTypeX = Text -> Either Text a
forall a b. a -> Either a b
Left Text
"unexpected 'max' type"
instance FromCursor CfValue where
fromCursor :: Cursor -> [CfValue]
fromCursor = (CfValue -> CfValue)
-> [CfValue] -> [CfValue] -> Cursor -> [CfValue]
forall a. (CfValue -> a) -> [a] -> [a] -> Cursor -> [a]
readCfValue CfValue -> CfValue
forall a. a -> a
id [CfValue]
forall a. [a]
failMinCfvType [CfValue]
forall a. [a]
failMaxCfvType
instance FromXenoNode CfValue where
fromXenoNode :: Node -> Either Text CfValue
fromXenoNode Node
root = (CfValue -> CfValue)
-> Either Text CfValue
-> Either Text CfValue
-> Node
-> Either Text CfValue
forall a.
(CfValue -> a)
-> Either Text a -> Either Text a -> Node -> Either Text a
readCfValueX CfValue -> CfValue
forall a. a -> a
id Either Text CfValue
forall a. Either Text a
failMinCfvTypeX Either Text CfValue
forall a. Either Text a
failMaxCfvTypeX Node
root
instance FromCursor MinCfValue where
fromCursor :: Cursor -> [MinCfValue]
fromCursor = (CfValue -> MinCfValue)
-> [MinCfValue] -> [MinCfValue] -> Cursor -> [MinCfValue]
forall a. (CfValue -> a) -> [a] -> [a] -> Cursor -> [a]
readCfValue CfValue -> MinCfValue
MinCfValue (MinCfValue -> [MinCfValue]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return MinCfValue
CfvMin) [MinCfValue]
forall a. [a]
failMaxCfvType
instance FromXenoNode MinCfValue where
fromXenoNode :: Node -> Either Text MinCfValue
fromXenoNode Node
root =
(CfValue -> MinCfValue)
-> Either Text MinCfValue
-> Either Text MinCfValue
-> Node
-> Either Text MinCfValue
forall a.
(CfValue -> a)
-> Either Text a -> Either Text a -> Node -> Either Text a
readCfValueX CfValue -> MinCfValue
MinCfValue (MinCfValue -> Either Text MinCfValue
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return MinCfValue
CfvMin) Either Text MinCfValue
forall a. Either Text a
failMaxCfvTypeX Node
root
instance FromCursor MaxCfValue where
fromCursor :: Cursor -> [MaxCfValue]
fromCursor = (CfValue -> MaxCfValue)
-> [MaxCfValue] -> [MaxCfValue] -> Cursor -> [MaxCfValue]
forall a. (CfValue -> a) -> [a] -> [a] -> Cursor -> [a]
readCfValue CfValue -> MaxCfValue
MaxCfValue [MaxCfValue]
forall a. [a]
failMinCfvType (MaxCfValue -> [MaxCfValue]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return MaxCfValue
CfvMax)
instance FromXenoNode MaxCfValue where
fromXenoNode :: Node -> Either Text MaxCfValue
fromXenoNode Node
root =
(CfValue -> MaxCfValue)
-> Either Text MaxCfValue
-> Either Text MaxCfValue
-> Node
-> Either Text MaxCfValue
forall a.
(CfValue -> a)
-> Either Text a -> Either Text a -> Node -> Either Text a
readCfValueX CfValue -> MaxCfValue
MaxCfValue Either Text MaxCfValue
forall a. Either Text a
failMinCfvTypeX (MaxCfValue -> Either Text MaxCfValue
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return MaxCfValue
CfvMax) Node
root
defaultIconSet :: IconSetType
defaultIconSet :: IconSetType
defaultIconSet = IconSetType
IconSet3TrafficLights1
instance FromCursor IconSetOptions where
fromCursor :: Cursor -> [IconSetOptions]
fromCursor Cursor
cur = do
IconSetType
_isoIconSet <- Name -> IconSetType -> Cursor -> [IconSetType]
forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
fromAttributeDef Name
"iconSet" IconSetType
defaultIconSet Cursor
cur
let _isoValues :: [CfValue]
_isoValues = Cursor
cur Cursor -> (Cursor -> [CfValue]) -> [CfValue]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Name -> Axis
element (Text -> Name
n_ Text
"cfvo") Axis -> (Cursor -> [CfValue]) -> Cursor -> [CfValue]
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> Cursor -> [CfValue]
forall a. FromCursor a => Cursor -> [a]
fromCursor
Bool
_isoReverse <- Name -> Bool -> Cursor -> [Bool]
forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
fromAttributeDef Name
"reverse" Bool
False Cursor
cur
Bool
_isoShowValue <- Name -> Bool -> Cursor -> [Bool]
forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
fromAttributeDef Name
"showValue" Bool
True Cursor
cur
IconSetOptions -> [IconSetOptions]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetOptions {Bool
[CfValue]
IconSetType
_isoIconSet :: IconSetType
_isoValues :: [CfValue]
_isoReverse :: Bool
_isoShowValue :: Bool
_isoIconSet :: IconSetType
_isoValues :: [CfValue]
_isoReverse :: Bool
_isoShowValue :: Bool
..}
instance FromXenoNode IconSetOptions where
fromXenoNode :: Node -> Either Text IconSetOptions
fromXenoNode Node
root = do
(IconSetType
_isoIconSet, Bool
_isoReverse, Bool
_isoShowValue) <-
Node
-> AttrParser (IconSetType, Bool, Bool)
-> Either Text (IconSetType, Bool, Bool)
forall a. Node -> AttrParser a -> Either Text a
parseAttributes Node
root (AttrParser (IconSetType, Bool, Bool)
-> Either Text (IconSetType, Bool, Bool))
-> AttrParser (IconSetType, Bool, Bool)
-> Either Text (IconSetType, Bool, Bool)
forall a b. (a -> b) -> a -> b
$ (,,) (IconSetType -> Bool -> Bool -> (IconSetType, Bool, Bool))
-> AttrParser IconSetType
-> AttrParser (Bool -> Bool -> (IconSetType, Bool, Bool))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> IconSetType -> AttrParser IconSetType
forall a. FromAttrBs a => ByteString -> a -> AttrParser a
fromAttrDef ByteString
"iconSet" IconSetType
defaultIconSet
AttrParser (Bool -> Bool -> (IconSetType, Bool, Bool))
-> AttrParser Bool
-> AttrParser (Bool -> (IconSetType, Bool, Bool))
forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ByteString -> Bool -> AttrParser Bool
forall a. FromAttrBs a => ByteString -> a -> AttrParser a
fromAttrDef ByteString
"reverse" Bool
False
AttrParser (Bool -> (IconSetType, Bool, Bool))
-> AttrParser Bool -> AttrParser (IconSetType, Bool, Bool)
forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ByteString -> Bool -> AttrParser Bool
forall a. FromAttrBs a => ByteString -> a -> AttrParser a
fromAttrDef ByteString
"showValue" Bool
True
[CfValue]
_isoValues <- Node -> ChildCollector [CfValue] -> Either Text [CfValue]
forall a. Node -> ChildCollector a -> Either Text a
collectChildren Node
root (ChildCollector [CfValue] -> Either Text [CfValue])
-> ChildCollector [CfValue] -> Either Text [CfValue]
forall a b. (a -> b) -> a -> b
$ ByteString -> ChildCollector [CfValue]
forall a. FromXenoNode a => ByteString -> ChildCollector [a]
fromChildList ByteString
"cfvo"
IconSetOptions -> Either Text IconSetOptions
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetOptions {Bool
[CfValue]
IconSetType
_isoIconSet :: IconSetType
_isoValues :: [CfValue]
_isoReverse :: Bool
_isoShowValue :: Bool
_isoIconSet :: IconSetType
_isoReverse :: Bool
_isoShowValue :: Bool
_isoValues :: [CfValue]
..}
instance FromAttrVal IconSetType where
fromAttrVal :: Reader IconSetType
fromAttrVal Text
"3Arrows" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet3Arrows
fromAttrVal Text
"3ArrowsGray" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet3ArrowsGray
fromAttrVal Text
"3Flags" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet3Flags
fromAttrVal Text
"3Signs" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet3Signs
fromAttrVal Text
"3Symbols" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet3Symbols
fromAttrVal Text
"3Symbols2" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet3Symbols2
fromAttrVal Text
"3TrafficLights1" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet3TrafficLights1
fromAttrVal Text
"3TrafficLights2" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet3TrafficLights2
fromAttrVal Text
"4Arrows" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet4Arrows
fromAttrVal Text
"4ArrowsGray" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet4ArrowsGray
fromAttrVal Text
"4Rating" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet4Rating
fromAttrVal Text
"4RedToBlack" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet4RedToBlack
fromAttrVal Text
"4TrafficLights" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet4TrafficLights
fromAttrVal Text
"5Arrows" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet5Arrows
fromAttrVal Text
"5ArrowsGray" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet5ArrowsGray
fromAttrVal Text
"5Quarters" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet5Quarters
fromAttrVal Text
"5Rating" = IconSetType -> Either [Char] (IconSetType, Text)
forall a. a -> Either [Char] (a, Text)
readSuccess IconSetType
IconSet5Rating
fromAttrVal Text
t = Text -> Reader IconSetType
forall a. Text -> Text -> Either [Char] (a, Text)
invalidText Text
"IconSetType" Text
t
instance FromAttrBs IconSetType where
fromAttrBs :: ByteString -> Either Text IconSetType
fromAttrBs ByteString
"3Arrows" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet3Arrows
fromAttrBs ByteString
"3ArrowsGray" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet3ArrowsGray
fromAttrBs ByteString
"3Flags" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet3Flags
fromAttrBs ByteString
"3Signs" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet3Signs
fromAttrBs ByteString
"3Symbols" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet3Symbols
fromAttrBs ByteString
"3Symbols2" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet3Symbols2
fromAttrBs ByteString
"3TrafficLights1" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet3TrafficLights1
fromAttrBs ByteString
"3TrafficLights2" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet3TrafficLights2
fromAttrBs ByteString
"4Arrows" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet4Arrows
fromAttrBs ByteString
"4ArrowsGray" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet4ArrowsGray
fromAttrBs ByteString
"4Rating" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet4Rating
fromAttrBs ByteString
"4RedToBlack" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet4RedToBlack
fromAttrBs ByteString
"4TrafficLights" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet4TrafficLights
fromAttrBs ByteString
"5Arrows" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet5Arrows
fromAttrBs ByteString
"5ArrowsGray" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet5ArrowsGray
fromAttrBs ByteString
"5Quarters" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet5Quarters
fromAttrBs ByteString
"5Rating" = IconSetType -> Either Text IconSetType
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return IconSetType
IconSet5Rating
fromAttrBs ByteString
x = Text -> ByteString -> Either Text IconSetType
forall a. Text -> ByteString -> Either Text a
unexpectedAttrBs Text
"IconSetType" ByteString
x
instance FromCursor DataBarOptions where
fromCursor :: Cursor -> [DataBarOptions]
fromCursor Cursor
cur = do
Int
_dboMaxLength <- Name -> Int -> Cursor -> [Int]
forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
fromAttributeDef Name
"maxLength" Int
defaultDboMaxLength Cursor
cur
Int
_dboMinLength <- Name -> Int -> Cursor -> [Int]
forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
fromAttributeDef Name
"minLength" Int
defaultDboMinLength Cursor
cur
Bool
_dboShowValue <- Name -> Bool -> Cursor -> [Bool]
forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
fromAttributeDef Name
"showValue" Bool
True Cursor
cur
let cfvos :: [Node]
cfvos = Cursor
cur Cursor -> (Cursor -> [Node]) -> [Node]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Name -> Axis
element (Text -> Name
n_ Text
"cfvo") Axis -> (Cursor -> Node) -> Cursor -> [Node]
forall node a b.
(Cursor node -> [a]) -> (a -> b) -> Cursor node -> [b]
&| Cursor -> Node
forall node. Cursor node -> node
node
case [Node]
cfvos of
[Node
nMin, Node
nMax] -> do
MinCfValue
_dboMinimum <- Cursor -> [MinCfValue]
forall a. FromCursor a => Cursor -> [a]
fromCursor (Node -> Cursor
fromNode Node
nMin)
MaxCfValue
_dboMaximum <- Cursor -> [MaxCfValue]
forall a. FromCursor a => Cursor -> [a]
fromCursor (Node -> Cursor
fromNode Node
nMax)
Color
_dboColor <- Cursor
cur Cursor -> (Cursor -> [Color]) -> [Color]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Name -> Axis
element (Text -> Name
n_ Text
"color") Axis -> (Cursor -> [Color]) -> Cursor -> [Color]
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> Cursor -> [Color]
forall a. FromCursor a => Cursor -> [a]
fromCursor
DataBarOptions -> [DataBarOptions]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return DataBarOptions{Bool
Int
Color
MaxCfValue
MinCfValue
_dboMaxLength :: Int
_dboMinLength :: Int
_dboShowValue :: Bool
_dboMinimum :: MinCfValue
_dboMaximum :: MaxCfValue
_dboColor :: Color
_dboMaxLength :: Int
_dboMinLength :: Int
_dboShowValue :: Bool
_dboMinimum :: MinCfValue
_dboMaximum :: MaxCfValue
_dboColor :: Color
..}
[Node]
ns -> do
[Char] -> [DataBarOptions]
forall a. [Char] -> [a]
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail ([Char] -> [DataBarOptions]) -> [Char] -> [DataBarOptions]
forall a b. (a -> b) -> a -> b
$ [Char]
"expected minimum and maximum cfvo nodes but see instead " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++
Int -> [Char]
forall a. Show a => a -> [Char]
show ([Node] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Node]
ns) [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char]
" cfvo nodes"
instance FromXenoNode DataBarOptions where
fromXenoNode :: Node -> Either Text DataBarOptions
fromXenoNode Node
root = do
(Int
_dboMaxLength, Int
_dboMinLength, Bool
_dboShowValue) <-
Node -> AttrParser (Int, Int, Bool) -> Either Text (Int, Int, Bool)
forall a. Node -> AttrParser a -> Either Text a
parseAttributes Node
root (AttrParser (Int, Int, Bool) -> Either Text (Int, Int, Bool))
-> AttrParser (Int, Int, Bool) -> Either Text (Int, Int, Bool)
forall a b. (a -> b) -> a -> b
$ (,,) (Int -> Int -> Bool -> (Int, Int, Bool))
-> AttrParser Int -> AttrParser (Int -> Bool -> (Int, Int, Bool))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Int -> AttrParser Int
forall a. FromAttrBs a => ByteString -> a -> AttrParser a
fromAttrDef ByteString
"maxLength" Int
defaultDboMaxLength
AttrParser (Int -> Bool -> (Int, Int, Bool))
-> AttrParser Int -> AttrParser (Bool -> (Int, Int, Bool))
forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ByteString -> Int -> AttrParser Int
forall a. FromAttrBs a => ByteString -> a -> AttrParser a
fromAttrDef ByteString
"minLength" Int
defaultDboMinLength
AttrParser (Bool -> (Int, Int, Bool))
-> AttrParser Bool -> AttrParser (Int, Int, Bool)
forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ByteString -> Bool -> AttrParser Bool
forall a. FromAttrBs a => ByteString -> a -> AttrParser a
fromAttrDef ByteString
"showValue" Bool
True
(MinCfValue
_dboMinimum, MaxCfValue
_dboMaximum, Color
_dboColor) <-
Node
-> ChildCollector (MinCfValue, MaxCfValue, Color)
-> Either Text (MinCfValue, MaxCfValue, Color)
forall a. Node -> ChildCollector a -> Either Text a
collectChildren Node
root (ChildCollector (MinCfValue, MaxCfValue, Color)
-> Either Text (MinCfValue, MaxCfValue, Color))
-> ChildCollector (MinCfValue, MaxCfValue, Color)
-> Either Text (MinCfValue, MaxCfValue, Color)
forall a b. (a -> b) -> a -> b
$ (,,) (MinCfValue
-> MaxCfValue -> Color -> (MinCfValue, MaxCfValue, Color))
-> ChildCollector MinCfValue
-> ChildCollector
(MaxCfValue -> Color -> (MinCfValue, MaxCfValue, Color))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> ChildCollector MinCfValue
forall a. FromXenoNode a => ByteString -> ChildCollector a
fromChild ByteString
"cfvo"
ChildCollector
(MaxCfValue -> Color -> (MinCfValue, MaxCfValue, Color))
-> ChildCollector MaxCfValue
-> ChildCollector (Color -> (MinCfValue, MaxCfValue, Color))
forall a b.
ChildCollector (a -> b) -> ChildCollector a -> ChildCollector b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ByteString -> ChildCollector MaxCfValue
forall a. FromXenoNode a => ByteString -> ChildCollector a
fromChild ByteString
"cfvo"
ChildCollector (Color -> (MinCfValue, MaxCfValue, Color))
-> ChildCollector Color
-> ChildCollector (MinCfValue, MaxCfValue, Color)
forall a b.
ChildCollector (a -> b) -> ChildCollector a -> ChildCollector b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ByteString -> ChildCollector Color
forall a. FromXenoNode a => ByteString -> ChildCollector a
fromChild ByteString
"color"
DataBarOptions -> Either Text DataBarOptions
forall a. a -> Either Text a
forall (m :: * -> *) a. Monad m => a -> m a
return DataBarOptions{Bool
Int
Color
MaxCfValue
MinCfValue
_dboMaxLength :: Int
_dboMinLength :: Int
_dboShowValue :: Bool
_dboMinimum :: MinCfValue
_dboMaximum :: MaxCfValue
_dboColor :: Color
_dboMaxLength :: Int
_dboMinLength :: Int
_dboShowValue :: Bool
_dboMinimum :: MinCfValue
_dboMaximum :: MaxCfValue
_dboColor :: Color
..}
instance FromAttrVal Inclusion where
fromAttrVal :: Reader Inclusion
fromAttrVal = ((Bool, Text) -> (Inclusion, Text))
-> Either [Char] (Bool, Text) -> Either [Char] (Inclusion, Text)
forall b c d. (b -> c) -> Either d b -> Either d c
forall (a :: * -> * -> *) b c d.
ArrowChoice a =>
a b c -> a (Either d b) (Either d c)
right ((Bool -> Inclusion) -> (Bool, Text) -> (Inclusion, Text)
forall b c d. (b -> c) -> (b, d) -> (c, d)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first ((Bool -> Inclusion) -> (Bool, Text) -> (Inclusion, Text))
-> (Bool -> Inclusion) -> (Bool, Text) -> (Inclusion, Text)
forall a b. (a -> b) -> a -> b
$ Inclusion -> Inclusion -> Bool -> Inclusion
forall a. a -> a -> Bool -> a
bool Inclusion
Exclusive Inclusion
Inclusive) (Either [Char] (Bool, Text) -> Either [Char] (Inclusion, Text))
-> (Text -> Either [Char] (Bool, Text)) -> Reader Inclusion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Either [Char] (Bool, Text)
forall a. FromAttrVal a => Reader a
fromAttrVal
instance FromAttrBs Inclusion where
fromAttrBs :: ByteString -> Either Text Inclusion
fromAttrBs = (Bool -> Inclusion) -> Either Text Bool -> Either Text Inclusion
forall a b. (a -> b) -> Either Text a -> Either Text b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Inclusion -> Inclusion -> Bool -> Inclusion
forall a. a -> a -> Bool -> a
bool Inclusion
Exclusive Inclusion
Inclusive) (Either Text Bool -> Either Text Inclusion)
-> (ByteString -> Either Text Bool)
-> ByteString
-> Either Text Inclusion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Either Text Bool
forall a. FromAttrBs a => ByteString -> Either Text a
fromAttrBs
instance FromAttrVal NStdDev where
fromAttrVal :: Reader NStdDev
fromAttrVal = ((Int, Text) -> (NStdDev, Text))
-> Either [Char] (Int, Text) -> Either [Char] (NStdDev, Text)
forall b c d. (b -> c) -> Either d b -> Either d c
forall (a :: * -> * -> *) b c d.
ArrowChoice a =>
a b c -> a (Either d b) (Either d c)
right ((Int -> NStdDev) -> (Int, Text) -> (NStdDev, Text)
forall b c d. (b -> c) -> (b, d) -> (c, d)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first Int -> NStdDev
NStdDev) (Either [Char] (Int, Text) -> Either [Char] (NStdDev, Text))
-> (Text -> Either [Char] (Int, Text)) -> Reader NStdDev
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Either [Char] (Int, Text)
forall a. FromAttrVal a => Reader a
fromAttrVal
instance FromAttrBs NStdDev where
fromAttrBs :: ByteString -> Either Text NStdDev
fromAttrBs = (Int -> NStdDev) -> Either Text Int -> Either Text NStdDev
forall a b. (a -> b) -> Either Text a -> Either Text b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> NStdDev
NStdDev (Either Text Int -> Either Text NStdDev)
-> (ByteString -> Either Text Int)
-> ByteString
-> Either Text NStdDev
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Either Text Int
forall a. FromAttrBs a => ByteString -> Either Text a
fromAttrBs
instance ToElement CfRule where
toElement :: Name -> CfRule -> Element
toElement Name
nm CfRule{Int
Maybe Bool
Maybe Int
Condition
_cfrCondition :: CfRule -> Condition
_cfrDxfId :: CfRule -> Maybe Int
_cfrPriority :: CfRule -> Int
_cfrStopIfTrue :: CfRule -> Maybe Bool
_cfrCondition :: Condition
_cfrDxfId :: Maybe Int
_cfrPriority :: Int
_cfrStopIfTrue :: Maybe Bool
..} =
let (Text
condType, Map Name Text
condAttrs, [Node]
condNodes) = Condition -> (Text, Map Name Text, [Node])
conditionData Condition
_cfrCondition
baseAttrs :: Map Name Text
baseAttrs = [(Name, Text)] -> Map Name Text
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList ([(Name, Text)] -> Map Name Text)
-> ([Maybe (Name, Text)] -> [(Name, Text)])
-> [Maybe (Name, Text)]
-> Map Name Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe (Name, Text)] -> [(Name, Text)]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe (Name, Text)] -> Map Name Text)
-> [Maybe (Name, Text)] -> Map Name Text
forall a b. (a -> b) -> a -> b
$
[ (Name, Text) -> Maybe (Name, Text)
forall a. a -> Maybe a
Just ((Name, Text) -> Maybe (Name, Text))
-> (Name, Text) -> Maybe (Name, Text)
forall a b. (a -> b) -> a -> b
$ Name
"type" Name -> Text -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Text
condType
, Name
"dxfId" Name -> Maybe Int -> Maybe (Name, Text)
forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
.=? Maybe Int
_cfrDxfId
, (Name, Text) -> Maybe (Name, Text)
forall a. a -> Maybe a
Just ((Name, Text) -> Maybe (Name, Text))
-> (Name, Text) -> Maybe (Name, Text)
forall a b. (a -> b) -> a -> b
$ Name
"priority" Name -> Int -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Int
_cfrPriority
, Name
"stopIfTrue" Name -> Maybe Bool -> Maybe (Name, Text)
forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
.=? Maybe Bool
_cfrStopIfTrue
]
in Element
{ elementName :: Name
elementName = Name
nm
, elementAttributes :: Map Name Text
elementAttributes = Map Name Text -> Map Name Text -> Map Name Text
forall k a. Ord k => Map k a -> Map k a -> Map k a
M.union Map Name Text
baseAttrs Map Name Text
condAttrs
, elementNodes :: [Node]
elementNodes = [Node]
condNodes
}
conditionData :: Condition -> (Text, Map Name Text, [Node])
conditionData :: Condition -> (Text, Map Name Text, [Node])
conditionData (AboveAverage Inclusion
i Maybe NStdDev
sDevs) =
(Text
"aboveAverage", [(Name, Text)] -> Map Name Text
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList ([(Name, Text)] -> Map Name Text)
-> [(Name, Text)] -> Map Name Text
forall a b. (a -> b) -> a -> b
$ [Name
"aboveAverage" Name -> Bool -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Bool
True] [(Name, Text)] -> [(Name, Text)] -> [(Name, Text)]
forall a. [a] -> [a] -> [a]
++
[Maybe (Name, Text)] -> [(Name, Text)]
forall a. [Maybe a] -> [a]
catMaybes [ Name
"equalAverage" Name -> Maybe Inclusion -> Maybe (Name, Text)
forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
.=? Inclusion -> Inclusion -> Maybe Inclusion
forall a. Eq a => a -> a -> Maybe a
justNonDef Inclusion
Exclusive Inclusion
i
, Name
"stdDev" Name -> Maybe NStdDev -> Maybe (Name, Text)
forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
.=? Maybe NStdDev
sDevs], [])
conditionData (BeginsWith Text
t) = (Text
"beginsWith", [(Name, Text)] -> Map Name Text
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [ Name
"text" Name -> Text -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Text
t], [])
conditionData (BelowAverage Inclusion
i Maybe NStdDev
sDevs) =
(Text
"aboveAverage", [(Name, Text)] -> Map Name Text
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList ([(Name, Text)] -> Map Name Text)
-> [(Name, Text)] -> Map Name Text
forall a b. (a -> b) -> a -> b
$ [Name
"aboveAverage" Name -> Bool -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Bool
False] [(Name, Text)] -> [(Name, Text)] -> [(Name, Text)]
forall a. [a] -> [a] -> [a]
++
[Maybe (Name, Text)] -> [(Name, Text)]
forall a. [Maybe a] -> [a]
catMaybes [ Name
"equalAverage" Name -> Maybe Inclusion -> Maybe (Name, Text)
forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
.=? Inclusion -> Inclusion -> Maybe Inclusion
forall a. Eq a => a -> a -> Maybe a
justNonDef Inclusion
Exclusive Inclusion
i
, Name
"stdDev" Name -> Maybe NStdDev -> Maybe (Name, Text)
forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
.=? Maybe NStdDev
sDevs], [])
conditionData (BottomNPercent Int
n) = (Text
"top10", [(Name, Text)] -> Map Name Text
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [ Name
"bottom" Name -> Bool -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Bool
True, Name
"rank" Name -> Int -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Int
n, Name
"percent" Name -> Bool -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Bool
True ], [])
conditionData (BottomNValues Int
n) = (Text
"top10", [(Name, Text)] -> Map Name Text
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [ Name
"bottom" Name -> Bool -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Bool
True, Name
"rank" Name -> Int -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Int
n ], [])
conditionData (CellIs OperatorExpression
opExpr) = (Text
"cellIs", [(Name, Text)] -> Map Name Text
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [ Name
"operator" Name -> Text -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Text
op], [Node]
formulas)
where (Text
op, [Node]
formulas) = OperatorExpression -> (Text, [Node])
operatorExpressionData OperatorExpression
opExpr
conditionData (ColorScale2 MinCfValue
minv Color
minc MaxCfValue
maxv Color
maxc) =
( Text
"colorScale"
, Map Name Text
forall k a. Map k a
M.empty
, [ Element -> Node
NodeElement (Element -> Node) -> Element -> Node
forall a b. (a -> b) -> a -> b
$
Name -> [Element] -> Element
elementListSimple
Name
"colorScale"
[ Name -> MinCfValue -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
"cfvo" MinCfValue
minv
, Name -> MaxCfValue -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
"cfvo" MaxCfValue
maxv
, Name -> Color -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
"color" Color
minc
, Name -> Color -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
"color" Color
maxc
]
])
conditionData (ColorScale3 MinCfValue
minv Color
minc CfValue
midv Color
midc MaxCfValue
maxv Color
maxc) =
( Text
"colorScale"
, Map Name Text
forall k a. Map k a
M.empty
, [ Element -> Node
NodeElement (Element -> Node) -> Element -> Node
forall a b. (a -> b) -> a -> b
$
Name -> [Element] -> Element
elementListSimple
Name
"colorScale"
[ Name -> MinCfValue -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
"cfvo" MinCfValue
minv
, Name -> CfValue -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
"cfvo" CfValue
midv
, Name -> MaxCfValue -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
"cfvo" MaxCfValue
maxv
, Name -> Color -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
"color" Color
minc
, Name -> Color -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
"color" Color
midc
, Name -> Color -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
"color" Color
maxc
]
])
conditionData Condition
ContainsBlanks = (Text
"containsBlanks", Map Name Text
forall k a. Map k a
M.empty, [])
conditionData Condition
ContainsErrors = (Text
"containsErrors", Map Name Text
forall k a. Map k a
M.empty, [])
conditionData (ContainsText Text
t) = (Text
"containsText", [(Name, Text)] -> Map Name Text
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [ Name
"text" Name -> Text -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Text
t], [])
conditionData (DataBar DataBarOptions
dbOpts) = (Text
"dataBar", Map Name Text
forall k a. Map k a
M.empty, [Name -> DataBarOptions -> Node
forall a. ToElement a => Name -> a -> Node
toNode Name
"dataBar" DataBarOptions
dbOpts])
conditionData Condition
DoesNotContainBlanks = (Text
"notContainsBlanks", Map Name Text
forall k a. Map k a
M.empty, [])
conditionData Condition
DoesNotContainErrors = (Text
"notContainsErrors", Map Name Text
forall k a. Map k a
M.empty, [])
conditionData (DoesNotContainText Text
t) = (Text
"notContainsText", [(Name, Text)] -> Map Name Text
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [ Name
"text" Name -> Text -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Text
t], [])
conditionData Condition
DuplicateValues = (Text
"duplicateValues", Map Name Text
forall k a. Map k a
M.empty, [])
conditionData (EndsWith Text
t) = (Text
"endsWith", [(Name, Text)] -> Map Name Text
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [ Name
"text" Name -> Text -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Text
t], [])
conditionData (Expression Formula
formula) = (Text
"expression", Map Name Text
forall k a. Map k a
M.empty, [Formula -> Node
formulaNode Formula
formula])
conditionData (InTimePeriod TimePeriod
period) = (Text
"timePeriod", [(Name, Text)] -> Map Name Text
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [ Name
"timePeriod" Name -> TimePeriod -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= TimePeriod
period ], [])
conditionData (IconSet IconSetOptions
isOptions) = (Text
"iconSet", Map Name Text
forall k a. Map k a
M.empty, [Name -> IconSetOptions -> Node
forall a. ToElement a => Name -> a -> Node
toNode Name
"iconSet" IconSetOptions
isOptions])
conditionData (TopNPercent Int
n) = (Text
"top10", [(Name, Text)] -> Map Name Text
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [ Name
"rank" Name -> Int -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Int
n, Name
"percent" Name -> Bool -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Bool
True ], [])
conditionData (TopNValues Int
n) = (Text
"top10", [(Name, Text)] -> Map Name Text
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [ Name
"rank" Name -> Int -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Int
n ], [])
conditionData Condition
UniqueValues = (Text
"uniqueValues", Map Name Text
forall k a. Map k a
M.empty, [])
operatorExpressionData :: OperatorExpression -> (Text, [Node])
operatorExpressionData :: OperatorExpression -> (Text, [Node])
operatorExpressionData (OpBeginsWith Formula
f) = (Text
"beginsWith", [Formula -> Node
formulaNode Formula
f])
operatorExpressionData (OpBetween Formula
f1 Formula
f2) = (Text
"between", [Formula -> Node
formulaNode Formula
f1, Formula -> Node
formulaNode Formula
f2])
operatorExpressionData (OpContainsText Formula
f) = (Text
"containsText", [Formula -> Node
formulaNode Formula
f])
operatorExpressionData (OpEndsWith Formula
f) = (Text
"endsWith", [Formula -> Node
formulaNode Formula
f])
operatorExpressionData (OpEqual Formula
f) = (Text
"equal", [Formula -> Node
formulaNode Formula
f])
operatorExpressionData (OpGreaterThan Formula
f) = (Text
"greaterThan", [Formula -> Node
formulaNode Formula
f])
operatorExpressionData (OpGreaterThanOrEqual Formula
f) = (Text
"greaterThanOrEqual", [Formula -> Node
formulaNode Formula
f])
operatorExpressionData (OpLessThan Formula
f) = (Text
"lessThan", [Formula -> Node
formulaNode Formula
f])
operatorExpressionData (OpLessThanOrEqual Formula
f) = (Text
"lessThanOrEqual", [Formula -> Node
formulaNode Formula
f])
operatorExpressionData (OpNotBetween Formula
f1 Formula
f2) = (Text
"notBetween", [Formula -> Node
formulaNode Formula
f1, Formula -> Node
formulaNode Formula
f2])
operatorExpressionData (OpNotContains Formula
f) = (Text
"notContains", [Formula -> Node
formulaNode Formula
f])
operatorExpressionData (OpNotEqual Formula
f) = (Text
"notEqual", [Formula -> Node
formulaNode Formula
f])
instance ToElement MinCfValue where
toElement :: Name -> MinCfValue -> Element
toElement Name
nm MinCfValue
CfvMin = Name -> [(Name, Text)] -> Element
leafElement Name
nm [Name
"type" Name -> CfvType -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= CfvType
CfvtMin]
toElement Name
nm (MinCfValue CfValue
cfv) = Name -> CfValue -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
nm CfValue
cfv
instance ToElement MaxCfValue where
toElement :: Name -> MaxCfValue -> Element
toElement Name
nm MaxCfValue
CfvMax = Name -> [(Name, Text)] -> Element
leafElement Name
nm [Name
"type" Name -> CfvType -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= CfvType
CfvtMax]
toElement Name
nm (MaxCfValue CfValue
cfv) = Name -> CfValue -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
nm CfValue
cfv
instance ToElement CfValue where
toElement :: Name -> CfValue -> Element
toElement Name
nm (CfValue Double
v) = Name -> [(Name, Text)] -> Element
leafElement Name
nm [Name
"type" Name -> CfvType -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= CfvType
CfvtNum, Name
"val" Name -> Double -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Double
v]
toElement Name
nm (CfPercent Double
v) =
Name -> [(Name, Text)] -> Element
leafElement Name
nm [Name
"type" Name -> CfvType -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= CfvType
CfvtPercent, Name
"val" Name -> Double -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Double
v]
toElement Name
nm (CfPercentile Double
v) =
Name -> [(Name, Text)] -> Element
leafElement Name
nm [Name
"type" Name -> CfvType -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= CfvType
CfvtPercentile, Name
"val" Name -> Double -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Double
v]
toElement Name
nm (CfFormula Formula
f) =
Name -> [(Name, Text)] -> Element
leafElement Name
nm [Name
"type" Name -> CfvType -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= CfvType
CfvtFormula, Name
"val" Name -> Text -> (Name, Text)
forall a. ToAttrVal a => Name -> a -> (Name, Text)
.= Formula -> Text
unFormula Formula
f]
instance ToAttrVal CfvType where
toAttrVal :: CfvType -> Text
toAttrVal CfvType
CfvtNum = Text
"num"
toAttrVal CfvType
CfvtPercent = Text
"percent"
toAttrVal CfvType
CfvtMax = Text
"max"
toAttrVal CfvType
CfvtMin = Text
"min"
toAttrVal CfvType
CfvtFormula = Text
"formula"
toAttrVal CfvType
CfvtPercentile = Text
"percentile"
instance ToElement IconSetOptions where
toElement :: Name -> IconSetOptions -> Element
toElement Name
nm IconSetOptions {Bool
[CfValue]
IconSetType
_isoIconSet :: IconSetOptions -> IconSetType
_isoValues :: IconSetOptions -> [CfValue]
_isoReverse :: IconSetOptions -> Bool
_isoShowValue :: IconSetOptions -> Bool
_isoIconSet :: IconSetType
_isoValues :: [CfValue]
_isoReverse :: Bool
_isoShowValue :: Bool
..} =
Name -> [(Name, Text)] -> [Element] -> Element
elementList Name
nm [(Name, Text)]
attrs ([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ (CfValue -> Element) -> [CfValue] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map (Name -> CfValue -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
"cfvo") [CfValue]
_isoValues
where
attrs :: [(Name, Text)]
attrs = [Maybe (Name, Text)] -> [(Name, Text)]
forall a. [Maybe a] -> [a]
catMaybes
[ Name
"iconSet" Name -> Maybe IconSetType -> Maybe (Name, Text)
forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
.=? IconSetType -> IconSetType -> Maybe IconSetType
forall a. Eq a => a -> a -> Maybe a
justNonDef IconSetType
defaultIconSet IconSetType
_isoIconSet
, Name
"reverse" Name -> Maybe Bool -> Maybe (Name, Text)
forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
.=? Bool -> Maybe Bool
justTrue Bool
_isoReverse
, Name
"showValue" Name -> Maybe Bool -> Maybe (Name, Text)
forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
.=? Bool -> Maybe Bool
justFalse Bool
_isoShowValue
]
instance ToAttrVal IconSetType where
toAttrVal :: IconSetType -> Text
toAttrVal IconSetType
IconSet3Arrows = Text
"3Arrows"
toAttrVal IconSetType
IconSet3ArrowsGray = Text
"3ArrowsGray"
toAttrVal IconSetType
IconSet3Flags = Text
"3Flags"
toAttrVal IconSetType
IconSet3Signs = Text
"3Signs"
toAttrVal IconSetType
IconSet3Symbols = Text
"3Symbols"
toAttrVal IconSetType
IconSet3Symbols2 = Text
"3Symbols2"
toAttrVal IconSetType
IconSet3TrafficLights1 = Text
"3TrafficLights1"
toAttrVal IconSetType
IconSet3TrafficLights2 = Text
"3TrafficLights2"
toAttrVal IconSetType
IconSet4Arrows = Text
"4Arrows"
toAttrVal IconSetType
IconSet4ArrowsGray = Text
"4ArrowsGray"
toAttrVal IconSetType
IconSet4Rating = Text
"4Rating"
toAttrVal IconSetType
IconSet4RedToBlack = Text
"4RedToBlack"
toAttrVal IconSetType
IconSet4TrafficLights = Text
"4TrafficLights"
toAttrVal IconSetType
IconSet5Arrows = Text
"5Arrows"
toAttrVal IconSetType
IconSet5ArrowsGray = Text
"5ArrowsGray"
toAttrVal IconSetType
IconSet5Quarters = Text
"5Quarters"
toAttrVal IconSetType
IconSet5Rating = Text
"5Rating"
instance ToElement DataBarOptions where
toElement :: Name -> DataBarOptions -> Element
toElement Name
nm DataBarOptions {Bool
Int
Color
MaxCfValue
MinCfValue
_dboMaxLength :: DataBarOptions -> Int
_dboMinLength :: DataBarOptions -> Int
_dboShowValue :: DataBarOptions -> Bool
_dboMinimum :: DataBarOptions -> MinCfValue
_dboMaximum :: DataBarOptions -> MaxCfValue
_dboColor :: DataBarOptions -> Color
_dboMaxLength :: Int
_dboMinLength :: Int
_dboShowValue :: Bool
_dboMinimum :: MinCfValue
_dboMaximum :: MaxCfValue
_dboColor :: Color
..} = Name -> [(Name, Text)] -> [Element] -> Element
elementList Name
nm [(Name, Text)]
attrs [Element]
elements
where
attrs :: [(Name, Text)]
attrs = [Maybe (Name, Text)] -> [(Name, Text)]
forall a. [Maybe a] -> [a]
catMaybes
[ Name
"maxLength" Name -> Maybe Int -> Maybe (Name, Text)
forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
.=? Int -> Int -> Maybe Int
forall a. Eq a => a -> a -> Maybe a
justNonDef Int
defaultDboMaxLength Int
_dboMaxLength
, Name
"minLength" Name -> Maybe Int -> Maybe (Name, Text)
forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
.=? Int -> Int -> Maybe Int
forall a. Eq a => a -> a -> Maybe a
justNonDef Int
defaultDboMinLength Int
_dboMinLength
, Name
"showValue" Name -> Maybe Bool -> Maybe (Name, Text)
forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
.=? Bool -> Maybe Bool
justFalse Bool
_dboShowValue
]
elements :: [Element]
elements =
[ Name -> MinCfValue -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
"cfvo" MinCfValue
_dboMinimum
, Name -> MaxCfValue -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
"cfvo" MaxCfValue
_dboMaximum
, Name -> Color -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
"color" Color
_dboColor
]
toNode :: ToElement a => Name -> a -> Node
toNode :: forall a. ToElement a => Name -> a -> Node
toNode Name
nm = Element -> Node
NodeElement (Element -> Node) -> (a -> Element) -> a -> Node
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> a -> Element
forall a. ToElement a => Name -> a -> Element
toElement Name
nm
formulaNode :: Formula -> Node
formulaNode :: Formula -> Node
formulaNode = Name -> Formula -> Node
forall a. ToElement a => Name -> a -> Node
toNode Name
"formula"
instance ToAttrVal TimePeriod where
toAttrVal :: TimePeriod -> Text
toAttrVal TimePeriod
PerLast7Days = Text
"last7Days"
toAttrVal TimePeriod
PerLastMonth = Text
"lastMonth"
toAttrVal TimePeriod
PerLastWeek = Text
"lastWeek"
toAttrVal TimePeriod
PerNextMonth = Text
"nextMonth"
toAttrVal TimePeriod
PerNextWeek = Text
"nextWeek"
toAttrVal TimePeriod
PerThisMonth = Text
"thisMonth"
toAttrVal TimePeriod
PerThisWeek = Text
"thisWeek"
toAttrVal TimePeriod
PerToday = Text
"today"
toAttrVal TimePeriod
PerTomorrow = Text
"tomorrow"
toAttrVal TimePeriod
PerYesterday = Text
"yesterday"
instance ToAttrVal Inclusion where
toAttrVal :: Inclusion -> Text
toAttrVal = Bool -> Text
forall a. ToAttrVal a => a -> Text
toAttrVal (Bool -> Text) -> (Inclusion -> Bool) -> Inclusion -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Inclusion -> Inclusion -> Bool
forall a. Eq a => a -> a -> Bool
== Inclusion
Inclusive)
instance ToAttrVal NStdDev where
toAttrVal :: NStdDev -> Text
toAttrVal (NStdDev Int
n) = Int -> Text
forall a. ToAttrVal a => a -> Text
toAttrVal Int
n