    {-# LANGUAGE CPP #-}
    {-# LANGUAGE FlexibleInstances #-}
    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE RecordWildCards #-}
    {-# LANGUAGE ScopedTypeVariables #-}
    {-# LANGUAGE TemplateHaskell #-}
    {-# LANGUAGE DeriveGeneric #-}
    module Codec.Xlsx.Types.AutoFilter where

    import Control.Arrow (first)
    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.Foldable (asum)
    import Data.Map (Map)
    import qualified Data.Map as M
    import Data.Maybe (catMaybes)
    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.ConditionalFormatting (IconSetType)
    import Codec.Xlsx.Writer.Internal

    -- | The filterColumn collection identifies a particular column in the
    -- AutoFilter range and specifies filter information that has been
    -- applied to this column. If a column in the AutoFilter range has no
    -- criteria specified, then there is no corresponding filterColumn
    -- collection expressed for that column.
    --
    -- See 18.3.2.7 "filterColumn (AutoFilter Column)" (p. 1717)
    data FilterColumn
      = Filters FilterByBlank [FilterCriterion]
      | ColorFilter ColorFilterOptions
      | ACustomFilter CustomFilter
      | CustomFiltersOr CustomFilter CustomFilter
      | CustomFiltersAnd CustomFilter CustomFilter
      | DynamicFilter DynFilterOptions
      | IconFilter (Maybe Int) IconSetType
      -- ^ Specifies the icon set and particular icon within that set to
      -- filter by. Icon is specified using zero-based index of an icon in
      -- an icon set. 'Nothing' means "no icon"
      | BottomNFilter EdgeFilterOptions
      -- ^ Specifies the bottom N (percent or number of items) to filter by
      | TopNFilter EdgeFilterOptions
      -- ^ Specifies the top N (percent or number of items) to filter by
      deriving (FilterColumn -> FilterColumn -> Bool
    (FilterColumn -> FilterColumn -> Bool)
    -> (FilterColumn -> FilterColumn -> Bool) -> Eq FilterColumn
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: FilterColumn -> FilterColumn -> Bool
    == :: FilterColumn -> FilterColumn -> Bool
    $c/= :: FilterColumn -> FilterColumn -> Bool
    /= :: FilterColumn -> FilterColumn -> Bool
    Eq, Int -> FilterColumn -> ShowS
    [FilterColumn] -> ShowS
    FilterColumn -> [Char]
    (Int -> FilterColumn -> ShowS)
    -> (FilterColumn -> [Char])
    -> ([FilterColumn] -> ShowS)
    -> Show FilterColumn
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> FilterColumn -> ShowS
    showsPrec :: Int -> FilterColumn -> ShowS
    $cshow :: FilterColumn -> [Char]
    show :: FilterColumn -> [Char]
    $cshowList :: [FilterColumn] -> ShowS
    showList :: [FilterColumn] -> ShowS
    Show, (forall x. FilterColumn -> Rep FilterColumn x)
    -> (forall x. Rep FilterColumn x -> FilterColumn)
    -> Generic FilterColumn
    forall x. Rep FilterColumn x -> FilterColumn
    forall x. FilterColumn -> Rep FilterColumn x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. FilterColumn -> Rep FilterColumn x
    from :: forall x. FilterColumn -> Rep FilterColumn x
    $cto :: forall x. Rep FilterColumn x -> FilterColumn
    to :: forall x. Rep FilterColumn x -> FilterColumn
    Generic)
    instance NFData FilterColumn

    data FilterByBlank
      = FilterByBlank
      | DontFilterByBlank
      deriving (FilterByBlank -> FilterByBlank -> Bool
    (FilterByBlank -> FilterByBlank -> Bool)
    -> (FilterByBlank -> FilterByBlank -> Bool) -> Eq FilterByBlank
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: FilterByBlank -> FilterByBlank -> Bool
    == :: FilterByBlank -> FilterByBlank -> Bool
    $c/= :: FilterByBlank -> FilterByBlank -> Bool
    /= :: FilterByBlank -> FilterByBlank -> Bool
    Eq, Int -> FilterByBlank -> ShowS
    [FilterByBlank] -> ShowS
    FilterByBlank -> [Char]
    (Int -> FilterByBlank -> ShowS)
    -> (FilterByBlank -> [Char])
    -> ([FilterByBlank] -> ShowS)
    -> Show FilterByBlank
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> FilterByBlank -> ShowS
    showsPrec :: Int -> FilterByBlank -> ShowS
    $cshow :: FilterByBlank -> [Char]
    show :: FilterByBlank -> [Char]
    $cshowList :: [FilterByBlank] -> ShowS
    showList :: [FilterByBlank] -> ShowS
    Show, (forall x. FilterByBlank -> Rep FilterByBlank x)
    -> (forall x. Rep FilterByBlank x -> FilterByBlank)
    -> Generic FilterByBlank
    forall x. Rep FilterByBlank x -> FilterByBlank
    forall x. FilterByBlank -> Rep FilterByBlank x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. FilterByBlank -> Rep FilterByBlank x
    from :: forall x. FilterByBlank -> Rep FilterByBlank x
    $cto :: forall x. Rep FilterByBlank x -> FilterByBlank
    to :: forall x. Rep FilterByBlank x -> FilterByBlank
    Generic)
    instance NFData FilterByBlank

    data FilterCriterion
      = FilterValue Text
      | FilterDateGroup DateGroup
      deriving (FilterCriterion -> FilterCriterion -> Bool
    (FilterCriterion -> FilterCriterion -> Bool)
    -> (FilterCriterion -> FilterCriterion -> Bool)
    -> Eq FilterCriterion
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: FilterCriterion -> FilterCriterion -> Bool
    == :: FilterCriterion -> FilterCriterion -> Bool
    $c/= :: FilterCriterion -> FilterCriterion -> Bool
    /= :: FilterCriterion -> FilterCriterion -> Bool
    Eq, Int -> FilterCriterion -> ShowS
    [FilterCriterion] -> ShowS
    FilterCriterion -> [Char]
    (Int -> FilterCriterion -> ShowS)
    -> (FilterCriterion -> [Char])
    -> ([FilterCriterion] -> ShowS)
    -> Show FilterCriterion
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> FilterCriterion -> ShowS
    showsPrec :: Int -> FilterCriterion -> ShowS
    $cshow :: FilterCriterion -> [Char]
    show :: FilterCriterion -> [Char]
    $cshowList :: [FilterCriterion] -> ShowS
    showList :: [FilterCriterion] -> ShowS
    Show, (forall x. FilterCriterion -> Rep FilterCriterion x)
    -> (forall x. Rep FilterCriterion x -> FilterCriterion)
    -> Generic FilterCriterion
    forall x. Rep FilterCriterion x -> FilterCriterion
    forall x. FilterCriterion -> Rep FilterCriterion x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. FilterCriterion -> Rep FilterCriterion x
    from :: forall x. FilterCriterion -> Rep FilterCriterion x
    $cto :: forall x. Rep FilterCriterion x -> FilterCriterion
    to :: forall x. Rep FilterCriterion x -> FilterCriterion
    Generic)
    instance NFData FilterCriterion

    -- | Used to express a group of dates or times which are used in an
    -- AutoFilter criteria
    --
    -- Section 18.3.2.4 "dateGroupItem (Date Grouping)" (p. 1714)
    data DateGroup
      = DateGroupByYear Int
      | DateGroupByMonth Int Int
      | DateGroupByDay Int Int Int
      | DateGroupByHour Int Int Int Int
      | DateGroupByMinute Int Int Int Int Int
      | DateGroupBySecond Int Int Int Int Int Int
      deriving (DateGroup -> DateGroup -> Bool
    (DateGroup -> DateGroup -> Bool)
    -> (DateGroup -> DateGroup -> Bool) -> Eq DateGroup
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: DateGroup -> DateGroup -> Bool
    == :: DateGroup -> DateGroup -> Bool
    $c/= :: DateGroup -> DateGroup -> Bool
    /= :: DateGroup -> DateGroup -> Bool
    Eq, Int -> DateGroup -> ShowS
    [DateGroup] -> ShowS
    DateGroup -> [Char]
    (Int -> DateGroup -> ShowS)
    -> (DateGroup -> [Char])
    -> ([DateGroup] -> ShowS)
    -> Show DateGroup
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> DateGroup -> ShowS
    showsPrec :: Int -> DateGroup -> ShowS
    $cshow :: DateGroup -> [Char]
    show :: DateGroup -> [Char]
    $cshowList :: [DateGroup] -> ShowS
    showList :: [DateGroup] -> ShowS
    Show, (forall x. DateGroup -> Rep DateGroup x)
    -> (forall x. Rep DateGroup x -> DateGroup) -> Generic DateGroup
    forall x. Rep DateGroup x -> DateGroup
    forall x. DateGroup -> Rep DateGroup x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. DateGroup -> Rep DateGroup x
    from :: forall x. DateGroup -> Rep DateGroup x
    $cto :: forall x. Rep DateGroup x -> DateGroup
    to :: forall x. Rep DateGroup x -> DateGroup
    Generic)
    instance NFData DateGroup

    data CustomFilter = CustomFilter
      { CustomFilter -> CustomFilterOperator
    cfltOperator :: CustomFilterOperator
      , CustomFilter -> Text
    cfltValue :: Text
      } deriving (CustomFilter -> CustomFilter -> Bool
    (CustomFilter -> CustomFilter -> Bool)
    -> (CustomFilter -> CustomFilter -> Bool) -> Eq CustomFilter
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: CustomFilter -> CustomFilter -> Bool
    == :: CustomFilter -> CustomFilter -> Bool
    $c/= :: CustomFilter -> CustomFilter -> Bool
    /= :: CustomFilter -> CustomFilter -> Bool
    Eq, Int -> CustomFilter -> ShowS
    [CustomFilter] -> ShowS
    CustomFilter -> [Char]
    (Int -> CustomFilter -> ShowS)
    -> (CustomFilter -> [Char])
    -> ([CustomFilter] -> ShowS)
    -> Show CustomFilter
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> CustomFilter -> ShowS
    showsPrec :: Int -> CustomFilter -> ShowS
    $cshow :: CustomFilter -> [Char]
    show :: CustomFilter -> [Char]
    $cshowList :: [CustomFilter] -> ShowS
    showList :: [CustomFilter] -> ShowS
    Show, (forall x. CustomFilter -> Rep CustomFilter x)
    -> (forall x. Rep CustomFilter x -> CustomFilter)
    -> Generic CustomFilter
    forall x. Rep CustomFilter x -> CustomFilter
    forall x. CustomFilter -> Rep CustomFilter x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. CustomFilter -> Rep CustomFilter x
    from :: forall x. CustomFilter -> Rep CustomFilter x
    $cto :: forall x. Rep CustomFilter x -> CustomFilter
    to :: forall x. Rep CustomFilter x -> CustomFilter
    Generic)
    instance NFData CustomFilter

    data CustomFilterOperator
      = FltrEqual
        -- ^ Show results which are equal to criteria.
      | FltrGreaterThan
        -- ^ Show results which are greater than criteria.
      | FltrGreaterThanOrEqual
        -- ^ Show results which are greater than or equal to criteria.
      | FltrLessThan
        -- ^ Show results which are less than criteria.
      | FltrLessThanOrEqual
        -- ^ Show results which are less than or equal to criteria.
      | FltrNotEqual
        -- ^ Show results which are not equal to criteria.
      deriving (CustomFilterOperator -> CustomFilterOperator -> Bool
    (CustomFilterOperator -> CustomFilterOperator -> Bool)
    -> (CustomFilterOperator -> CustomFilterOperator -> Bool)
    -> Eq CustomFilterOperator
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: CustomFilterOperator -> CustomFilterOperator -> Bool
    == :: CustomFilterOperator -> CustomFilterOperator -> Bool
    $c/= :: CustomFilterOperator -> CustomFilterOperator -> Bool
    /= :: CustomFilterOperator -> CustomFilterOperator -> Bool
    Eq, Int -> CustomFilterOperator -> ShowS
    [CustomFilterOperator] -> ShowS
    CustomFilterOperator -> [Char]
    (Int -> CustomFilterOperator -> ShowS)
    -> (CustomFilterOperator -> [Char])
    -> ([CustomFilterOperator] -> ShowS)
    -> Show CustomFilterOperator
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> CustomFilterOperator -> ShowS
    showsPrec :: Int -> CustomFilterOperator -> ShowS
    $cshow :: CustomFilterOperator -> [Char]
    show :: CustomFilterOperator -> [Char]
    $cshowList :: [CustomFilterOperator] -> ShowS
    showList :: [CustomFilterOperator] -> ShowS
    Show, (forall x. CustomFilterOperator -> Rep CustomFilterOperator x)
    -> (forall x. Rep CustomFilterOperator x -> CustomFilterOperator)
    -> Generic CustomFilterOperator
    forall x. Rep CustomFilterOperator x -> CustomFilterOperator
    forall x. CustomFilterOperator -> Rep CustomFilterOperator x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. CustomFilterOperator -> Rep CustomFilterOperator x
    from :: forall x. CustomFilterOperator -> Rep CustomFilterOperator x
    $cto :: forall x. Rep CustomFilterOperator x -> CustomFilterOperator
    to :: forall x. Rep CustomFilterOperator x -> CustomFilterOperator
    Generic)
    instance NFData CustomFilterOperator

    data EdgeFilterOptions = EdgeFilterOptions
      { EdgeFilterOptions -> Bool
    _efoUsePercents :: Bool
      -- ^ Flag indicating whether or not to filter by percent value of
      -- the column. A false value filters by number of items.
      , EdgeFilterOptions -> Double
    _efoVal :: Double
      -- ^ Top or bottom value to use as the filter criteria.
      -- Example: "Filter by Top 10 Percent" or "Filter by Top 5 Items"
      , EdgeFilterOptions -> Maybe Double
    _efoFilterVal :: Maybe Double
      -- ^ The actual cell value in the range which is used to perform the
      -- comparison for this filter.
      } deriving (EdgeFilterOptions -> EdgeFilterOptions -> Bool
    (EdgeFilterOptions -> EdgeFilterOptions -> Bool)
    -> (EdgeFilterOptions -> EdgeFilterOptions -> Bool)
    -> Eq EdgeFilterOptions
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: EdgeFilterOptions -> EdgeFilterOptions -> Bool
    == :: EdgeFilterOptions -> EdgeFilterOptions -> Bool
    $c/= :: EdgeFilterOptions -> EdgeFilterOptions -> Bool
    /= :: EdgeFilterOptions -> EdgeFilterOptions -> Bool
    Eq, Int -> EdgeFilterOptions -> ShowS
    [EdgeFilterOptions] -> ShowS
    EdgeFilterOptions -> [Char]
    (Int -> EdgeFilterOptions -> ShowS)
    -> (EdgeFilterOptions -> [Char])
    -> ([EdgeFilterOptions] -> ShowS)
    -> Show EdgeFilterOptions
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> EdgeFilterOptions -> ShowS
    showsPrec :: Int -> EdgeFilterOptions -> ShowS
    $cshow :: EdgeFilterOptions -> [Char]
    show :: EdgeFilterOptions -> [Char]
    $cshowList :: [EdgeFilterOptions] -> ShowS
    showList :: [EdgeFilterOptions] -> ShowS
    Show, (forall x. EdgeFilterOptions -> Rep EdgeFilterOptions x)
    -> (forall x. Rep EdgeFilterOptions x -> EdgeFilterOptions)
    -> Generic EdgeFilterOptions
    forall x. Rep EdgeFilterOptions x -> EdgeFilterOptions
    forall x. EdgeFilterOptions -> Rep EdgeFilterOptions x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. EdgeFilterOptions -> Rep EdgeFilterOptions x
    from :: forall x. EdgeFilterOptions -> Rep EdgeFilterOptions x
    $cto :: forall x. Rep EdgeFilterOptions x -> EdgeFilterOptions
    to :: forall x. Rep EdgeFilterOptions x -> EdgeFilterOptions
    Generic)
    instance NFData EdgeFilterOptions

    -- | Specifies the color to filter by and whether to use the cell's
    -- fill or font color in the filter criteria. If the cell's font or
    -- fill color does not match the color specified in the criteria, the
    -- rows corresponding to those cells are hidden from view.
    --
    -- See 18.3.2.1 "colorFilter (Color Filter Criteria)" (p. 1712)
    data ColorFilterOptions = ColorFilterOptions
      { ColorFilterOptions -> Bool
    _cfoCellColor :: Bool
      -- ^ Flag indicating whether or not to filter by the cell's fill
      -- color. 'True' indicates to filter by cell fill. 'False' indicates
      -- to filter by the cell's font color.
      --
      -- For rich text in cells, if the color specified appears in the
      -- cell at all, it shall be included in the filter.
      , ColorFilterOptions -> Maybe Int
    _cfoDxfId :: Maybe Int
      -- ^ Id of differential format record (dxf) in the Styles Part (see
      -- '_styleSheetDxfs') which expresses the color value to filter by.
      } deriving (ColorFilterOptions -> ColorFilterOptions -> Bool
    (ColorFilterOptions -> ColorFilterOptions -> Bool)
    -> (ColorFilterOptions -> ColorFilterOptions -> Bool)
    -> Eq ColorFilterOptions
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ColorFilterOptions -> ColorFilterOptions -> Bool
    == :: ColorFilterOptions -> ColorFilterOptions -> Bool
    $c/= :: ColorFilterOptions -> ColorFilterOptions -> Bool
    /= :: ColorFilterOptions -> ColorFilterOptions -> Bool
    Eq, Int -> ColorFilterOptions -> ShowS
    [ColorFilterOptions] -> ShowS
    ColorFilterOptions -> [Char]
    (Int -> ColorFilterOptions -> ShowS)
    -> (ColorFilterOptions -> [Char])
    -> ([ColorFilterOptions] -> ShowS)
    -> Show ColorFilterOptions
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ColorFilterOptions -> ShowS
    showsPrec :: Int -> ColorFilterOptions -> ShowS
    $cshow :: ColorFilterOptions -> [Char]
    show :: ColorFilterOptions -> [Char]
    $cshowList :: [ColorFilterOptions] -> ShowS
    showList :: [ColorFilterOptions] -> ShowS
    Show, (forall x. ColorFilterOptions -> Rep ColorFilterOptions x)
    -> (forall x. Rep ColorFilterOptions x -> ColorFilterOptions)
    -> Generic ColorFilterOptions
    forall x. Rep ColorFilterOptions x -> ColorFilterOptions
    forall x. ColorFilterOptions -> Rep ColorFilterOptions x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. ColorFilterOptions -> Rep ColorFilterOptions x
    from :: forall x. ColorFilterOptions -> Rep ColorFilterOptions x
    $cto :: forall x. Rep ColorFilterOptions x -> ColorFilterOptions
    to :: forall x. Rep ColorFilterOptions x -> ColorFilterOptions
    Generic)
    instance NFData ColorFilterOptions

    -- | Specifies dynamic filter criteria. These criteria are considered
    -- dynamic because they can change, either with the data itself (e.g.,
    -- "above average") or with the current system date (e.g., show values
    -- for "today"). For any cells whose values do not meet the specified
    -- criteria, the corresponding rows shall be hidden from view when the
    -- filter is applied.
    --
    -- '_dfoMaxVal' shall be required for 'DynFilterTday',
    -- 'DynFilterYesterday', 'DynFilterTomorrow', 'DynFilterNextWeek',
    -- 'DynFilterThisWeek', 'DynFilterLastWeek', 'DynFilterNextMonth',
    -- 'DynFilterThisMonth', 'DynFilterLastMonth', 'DynFilterNextQuarter',
    -- 'DynFilterThisQuarter', 'DynFilterLastQuarter',
    -- 'DynFilterNextYear', 'DynFilterThisYear', 'DynFilterLastYear', and
    -- 'DynFilterYearToDate.
    --
    -- The above criteria are based on a value range; that is, if today's
    -- date is September 22nd, then the range for thisWeek is the values
    -- greater than or equal to September 17 and less than September
    -- 24. In the thisWeek range, the lower value is expressed
    -- '_dfoval'. The higher value is expressed using '_dfoMmaxVal'.
    --
    -- These dynamic filters shall not require '_dfoVal or '_dfoMaxVal':
    -- 'DynFilterQ1', 'DynFilterQ2', 'DynFilterQ3', 'DynFilterQ4',
    -- 'DynFilterM1', 'DynFilterM2', 'DynFilterM3', 'DynFilterM4',
    -- 'DynFilterM5', 'DynFilterM6', 'DynFilterM7', 'DynFilterM8',
    -- 'DynFilterM9', 'DynFilterM10', 'DynFilterM11' and 'DynFilterM12'.
    --
    -- The above criteria shall not specify the range using valIso and
    -- maxValIso because Q1 always starts from M1 to M3, and M1 is always
    -- January.
    --
    -- These types of dynamic filters shall use valIso and shall not use
    -- '_dfoMaxVal': 'DynFilterAboveAverage' and 'DynFilterBelowAverage'
    --
    -- /Note:/ Specification lists 'valIso' and 'maxIso' to store datetime
    -- values but it appears that Excel doesn't use them and stored them
    -- as numeric values (as it does for datetimes in cell values)
    --
    -- See 18.3.2.5 "dynamicFilter (Dynamic Filter)" (p. 1715)
    data DynFilterOptions = DynFilterOptions
      { DynFilterOptions -> DynFilterType
    _dfoType :: DynFilterType
      , DynFilterOptions -> Maybe Double
    _dfoVal :: Maybe Double
      -- ^ A minimum numeric value for dynamic filter.
      , DynFilterOptions -> Maybe Double
    _dfoMaxVal :: Maybe Double
      -- ^ A maximum value for dynamic filter.
      } deriving (DynFilterOptions -> DynFilterOptions -> Bool
    (DynFilterOptions -> DynFilterOptions -> Bool)
    -> (DynFilterOptions -> DynFilterOptions -> Bool)
    -> Eq DynFilterOptions
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: DynFilterOptions -> DynFilterOptions -> Bool
    == :: DynFilterOptions -> DynFilterOptions -> Bool
    $c/= :: DynFilterOptions -> DynFilterOptions -> Bool
    /= :: DynFilterOptions -> DynFilterOptions -> Bool
    Eq, Int -> DynFilterOptions -> ShowS
    [DynFilterOptions] -> ShowS
    DynFilterOptions -> [Char]
    (Int -> DynFilterOptions -> ShowS)
    -> (DynFilterOptions -> [Char])
    -> ([DynFilterOptions] -> ShowS)
    -> Show DynFilterOptions
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> DynFilterOptions -> ShowS
    showsPrec :: Int -> DynFilterOptions -> ShowS
    $cshow :: DynFilterOptions -> [Char]
    show :: DynFilterOptions -> [Char]
    $cshowList :: [DynFilterOptions] -> ShowS
    showList :: [DynFilterOptions] -> ShowS
    Show, (forall x. DynFilterOptions -> Rep DynFilterOptions x)
    -> (forall x. Rep DynFilterOptions x -> DynFilterOptions)
    -> Generic DynFilterOptions
    forall x. Rep DynFilterOptions x -> DynFilterOptions
    forall x. DynFilterOptions -> Rep DynFilterOptions x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. DynFilterOptions -> Rep DynFilterOptions x
    from :: forall x. DynFilterOptions -> Rep DynFilterOptions x
    $cto :: forall x. Rep DynFilterOptions x -> DynFilterOptions
    to :: forall x. Rep DynFilterOptions x -> DynFilterOptions
    Generic)
    instance NFData DynFilterOptions

    -- | Specifies concrete type of dynamic filter used
    --
    -- See 18.18.26 "ST_DynamicFilterType (Dynamic Filter)" (p. 2452)
    data DynFilterType
      = DynFilterAboveAverage
      -- ^ Shows values that are above average.
      | DynFilterBelowAverage
      -- ^ Shows values that are below average.
      | DynFilterLastMonth
      -- ^ Shows last month's dates.
      | DynFilterLastQuarter
      -- ^ Shows last calendar quarter's dates.
      | DynFilterLastWeek
      -- ^ Shows last week's dates, using Sunday as the first weekday.
      | DynFilterLastYear
      -- ^ Shows last year's dates.
      | DynFilterM1
      -- ^ Shows the dates that are in January, regardless of year.
      | DynFilterM10
      -- ^ Shows the dates that are in October, regardless of year.
      | DynFilterM11
      -- ^ Shows the dates that are in November, regardless of year.
      | DynFilterM12
      -- ^ Shows the dates that are in December, regardless of year.
      | DynFilterM2
      -- ^ Shows the dates that are in February, regardless of year.
      | DynFilterM3
      -- ^ Shows the dates that are in March, regardless of year.
      | DynFilterM4
      -- ^ Shows the dates that are in April, regardless of year.
      | DynFilterM5
      -- ^ Shows the dates that are in May, regardless of year.
      | DynFilterM6
      -- ^ Shows the dates that are in June, regardless of year.
      | DynFilterM7
      -- ^ Shows the dates that are in July, regardless of year.
      | DynFilterM8
      -- ^ Shows the dates that are in August, regardless of year.
      | DynFilterM9
      -- ^ Shows the dates that are in September, regardless of year.
      | DynFilterNextMonth
      -- ^ Shows next month's dates.
      | DynFilterNextQuarter
      -- ^ Shows next calendar quarter's dates.
      | DynFilterNextWeek
      -- ^ Shows next week's dates, using Sunday as the first weekday.
      | DynFilterNextYear
      -- ^ Shows next year's dates.
      | DynFilterNull
      -- ^ Common filter type not available.
      | DynFilterQ1
      -- ^ Shows the dates that are in the 1st calendar quarter,
      -- regardless of year.
      | DynFilterQ2
      -- ^ Shows the dates that are in the 2nd calendar quarter,
      -- regardless of year.
      | DynFilterQ3
      -- ^ Shows the dates that are in the 3rd calendar quarter,
      -- regardless of year.
      | DynFilterQ4
      -- ^ Shows the dates that are in the 4th calendar quarter,
      -- regardless of year.
      | DynFilterThisMonth
      -- ^ Shows this month's dates.
      | DynFilterThisQuarter
      -- ^ Shows this calendar quarter's dates.
      | DynFilterThisWeek
      -- ^ Shows this week's dates, using Sunday as the first weekday.
      | DynFilterThisYear
      -- ^ Shows this year's dates.
      | DynFilterToday
      -- ^ Shows today's dates.
      | DynFilterTomorrow
      -- ^ Shows tomorrow's dates.
      | DynFilterYearToDate
      -- ^ Shows the dates between the beginning of the year and today, inclusive.
      | DynFilterYesterday
      -- ^ Shows yesterday's dates.
      deriving (DynFilterType -> DynFilterType -> Bool
    (DynFilterType -> DynFilterType -> Bool)
    -> (DynFilterType -> DynFilterType -> Bool) -> Eq DynFilterType
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: DynFilterType -> DynFilterType -> Bool
    == :: DynFilterType -> DynFilterType -> Bool
    $c/= :: DynFilterType -> DynFilterType -> Bool
    /= :: DynFilterType -> DynFilterType -> Bool
    Eq, Int -> DynFilterType -> ShowS
    [DynFilterType] -> ShowS
    DynFilterType -> [Char]
    (Int -> DynFilterType -> ShowS)
    -> (DynFilterType -> [Char])
    -> ([DynFilterType] -> ShowS)
    -> Show DynFilterType
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> DynFilterType -> ShowS
    showsPrec :: Int -> DynFilterType -> ShowS
    $cshow :: DynFilterType -> [Char]
    show :: DynFilterType -> [Char]
    $cshowList :: [DynFilterType] -> ShowS
    showList :: [DynFilterType] -> ShowS
    Show, (forall x. DynFilterType -> Rep DynFilterType x)
    -> (forall x. Rep DynFilterType x -> DynFilterType)
    -> Generic DynFilterType
    forall x. Rep DynFilterType x -> DynFilterType
    forall x. DynFilterType -> Rep DynFilterType x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. DynFilterType -> Rep DynFilterType x
    from :: forall x. DynFilterType -> Rep DynFilterType x
    $cto :: forall x. Rep DynFilterType x -> DynFilterType
    to :: forall x. Rep DynFilterType x -> DynFilterType
    Generic)
    instance NFData DynFilterType

    -- | AutoFilter temporarily hides rows based on a filter criteria,
    -- which is applied column by column to a table of datain the
    -- worksheet.
    --
    -- TODO: sortState, extList
    --
    -- See 18.3.1.2 "autoFilter (AutoFilter Settings)" (p. 1596)
    data AutoFilter = AutoFilter
      { AutoFilter -> Maybe CellRef
    _afRef :: Maybe CellRef
      , AutoFilter -> Map Int FilterColumn
    _afFilterColumns :: Map Int FilterColumn
      } deriving (AutoFilter -> AutoFilter -> Bool
    (AutoFilter -> AutoFilter -> Bool)
    -> (AutoFilter -> AutoFilter -> Bool) -> Eq AutoFilter
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: AutoFilter -> AutoFilter -> Bool
    == :: AutoFilter -> AutoFilter -> Bool
    $c/= :: AutoFilter -> AutoFilter -> Bool
    /= :: AutoFilter -> AutoFilter -> Bool
    Eq, Int -> AutoFilter -> ShowS
    [AutoFilter] -> ShowS
    AutoFilter -> [Char]
    (Int -> AutoFilter -> ShowS)
    -> (AutoFilter -> [Char])
    -> ([AutoFilter] -> ShowS)
    -> Show AutoFilter
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> AutoFilter -> ShowS
    showsPrec :: Int -> AutoFilter -> ShowS
    $cshow :: AutoFilter -> [Char]
    show :: AutoFilter -> [Char]
    $cshowList :: [AutoFilter] -> ShowS
    showList :: [AutoFilter] -> ShowS
    Show, (forall x. AutoFilter -> Rep AutoFilter x)
    -> (forall x. Rep AutoFilter x -> AutoFilter) -> Generic AutoFilter
    forall x. Rep AutoFilter x -> AutoFilter
    forall x. AutoFilter -> Rep AutoFilter x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. AutoFilter -> Rep AutoFilter x
    from :: forall x. AutoFilter -> Rep AutoFilter x
    $cto :: forall x. Rep AutoFilter x -> AutoFilter
    to :: forall x. Rep AutoFilter x -> AutoFilter
    Generic)
    instance NFData AutoFilter

    makeLenses ''AutoFilter

    {-------------------------------------------------------------------------------
      Default instances
    -------------------------------------------------------------------------------}

    instance Default AutoFilter where
        def :: AutoFilter
    def = Maybe CellRef -> Map Int FilterColumn -> AutoFilter
    AutoFilter Maybe CellRef
    forall a. Maybe a
    Nothing Map Int FilterColumn
    forall k a. Map k a
    M.empty

    {-------------------------------------------------------------------------------
      Parsing
    -------------------------------------------------------------------------------}

    instance FromCursor AutoFilter where
      fromCursor :: Cursor -> [AutoFilter]
    fromCursor Cursor
    cur = do
        _afRef <- Name -> Cursor -> [Maybe CellRef]
    forall a. FromAttrVal a => Name -> Cursor -> [Maybe a]
    maybeAttribute Name
    "ref" Cursor
    cur
        let _afFilterColumns = [(Int, FilterColumn)] -> Map Int FilterColumn
    forall k a. Ord k => [(k, a)] -> Map k a
    M.fromList ([(Int, FilterColumn)] -> Map Int FilterColumn)
    -> [(Int, FilterColumn)] -> Map Int FilterColumn
    forall a b. (a -> b) -> a -> b
    $ Cursor
    cur Cursor
    -> (Cursor -> [(Int, FilterColumn)]) -> [(Int, FilterColumn)]
    forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
    $/ Name -> Axis
    element (Text -> Name
    n_ Text
    "filterColumn") Axis
    -> (Cursor -> [(Int, FilterColumn)])
    -> Cursor
    -> [(Int, FilterColumn)]
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> \Cursor
    c -> do
              colId <- Name -> Cursor -> [Int]
    forall a. FromAttrVal a => Name -> Cursor -> [a]
    fromAttribute Name
    "colId" Cursor
    c
              fcol <- c $/ anyElement >=> fltColFromNode . node
              return (colId, fcol)
        return AutoFilter {..}

    instance FromXenoNode AutoFilter where
      fromXenoNode :: Node -> Either Text AutoFilter
    fromXenoNode Node
    root = do
        _afRef <- Node -> AttrParser (Maybe CellRef) -> Either Text (Maybe CellRef)
    forall a. Node -> AttrParser a -> Either Text a
    parseAttributes Node
    root (AttrParser (Maybe CellRef) -> Either Text (Maybe CellRef))
    -> AttrParser (Maybe CellRef) -> Either Text (Maybe CellRef)
    forall a b. (a -> b) -> a -> b
    $ ByteString -> AttrParser (Maybe CellRef)
    forall a. FromAttrBs a => ByteString -> AttrParser (Maybe a)
    maybeAttr ByteString
    "ref"
        _afFilterColumns <-
          fmap M.fromList . collectChildren root $ fromChildList "filterColumn"
        return AutoFilter {..}

    instance FromXenoNode (Int, FilterColumn) where
      fromXenoNode :: Node -> Either Text (Int, FilterColumn)
    fromXenoNode Node
    root = do
        colId <- Node -> AttrParser Int -> Either Text Int
    forall a. Node -> AttrParser a -> Either Text a
    parseAttributes Node
    root (AttrParser Int -> Either Text Int)
    -> AttrParser Int -> Either Text Int
    forall a b. (a -> b) -> a -> b
    $ ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "colId"
        fCol <-
          collectChildren root $ asum [filters, color, custom, dynamic, icon, top10]
        return (colId, fCol)
        where
          filters :: ChildCollector FilterColumn
    filters =
            ByteString
    -> (Node -> Either Text FilterColumn)
    -> ChildCollector FilterColumn
    forall a. ByteString -> (Node -> Either Text a) -> ChildCollector a
    requireAndParse ByteString
    "filters" ((Node -> Either Text FilterColumn) -> ChildCollector FilterColumn)
    -> (Node -> Either Text FilterColumn)
    -> ChildCollector FilterColumn
    forall a b. (a -> b) -> a -> b
    $ \Node
    node -> do
              filterBlank <-
                Node -> AttrParser FilterByBlank -> Either Text FilterByBlank
    forall a. Node -> AttrParser a -> Either Text a
    parseAttributes Node
    node (AttrParser FilterByBlank -> Either Text FilterByBlank)
    -> AttrParser FilterByBlank -> Either Text FilterByBlank
    forall a b. (a -> b) -> a -> b
    $ ByteString -> FilterByBlank -> AttrParser FilterByBlank
    forall a. FromAttrBs a => ByteString -> a -> AttrParser a
    fromAttrDef ByteString
    "blank" FilterByBlank
    DontFilterByBlank
              filterCriteria <- childListAny node
              return $ Filters filterBlank filterCriteria
          color :: ChildCollector FilterColumn
    color =
            ByteString
    -> (Node -> Either Text FilterColumn)
    -> ChildCollector FilterColumn
    forall a. ByteString -> (Node -> Either Text a) -> ChildCollector a
    requireAndParse ByteString
    "colorFilter" ((Node -> Either Text FilterColumn) -> ChildCollector FilterColumn)
    -> (Node -> Either Text FilterColumn)
    -> ChildCollector FilterColumn
    forall a b. (a -> b) -> a -> b
    $ \Node
    node ->
              Node -> AttrParser FilterColumn -> Either Text FilterColumn
    forall a. Node -> AttrParser a -> Either Text a
    parseAttributes Node
    node (AttrParser FilterColumn -> Either Text FilterColumn)
    -> AttrParser FilterColumn -> Either Text FilterColumn
    forall a b. (a -> b) -> a -> b
    $ do
                _cfoCellColor <- ByteString -> Bool -> AttrParser Bool
    forall a. FromAttrBs a => ByteString -> a -> AttrParser a
    fromAttrDef ByteString
    "cellColor" Bool
    True
                _cfoDxfId <- maybeAttr "dxfId"
                return $ ColorFilter ColorFilterOptions {..}
          custom :: ChildCollector FilterColumn
    custom =
            ByteString
    -> (Node -> Either Text FilterColumn)
    -> ChildCollector FilterColumn
    forall a. ByteString -> (Node -> Either Text a) -> ChildCollector a
    requireAndParse ByteString
    "customFilters" ((Node -> Either Text FilterColumn) -> ChildCollector FilterColumn)
    -> (Node -> Either Text FilterColumn)
    -> ChildCollector FilterColumn
    forall a b. (a -> b) -> a -> b
    $ \Node
    node -> do
              isAnd <- Node -> AttrParser Bool -> Either Text Bool
    forall a. Node -> AttrParser a -> Either Text a
    parseAttributes Node
    node (AttrParser Bool -> Either Text Bool)
    -> AttrParser Bool -> Either Text Bool
    forall a b. (a -> b) -> a -> b
    $ ByteString -> Bool -> AttrParser Bool
    forall a. FromAttrBs a => ByteString -> a -> AttrParser a
    fromAttrDef ByteString
    "and" Bool
    False
              cfilters <- collectChildren node $ fromChildList "customFilter"
              case cfilters of
                [CustomFilter
    f] -> FilterColumn -> Either Text FilterColumn
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (FilterColumn -> Either Text FilterColumn)
    -> FilterColumn -> Either Text FilterColumn
    forall a b. (a -> b) -> a -> b
    $ CustomFilter -> FilterColumn
    ACustomFilter CustomFilter
    f
                [CustomFilter
    f1, CustomFilter
    f2] ->
                  if Bool
    isAnd
                    then FilterColumn -> Either Text FilterColumn
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (FilterColumn -> Either Text FilterColumn)
    -> FilterColumn -> Either Text FilterColumn
    forall a b. (a -> b) -> a -> b
    $ CustomFilter -> CustomFilter -> FilterColumn
    CustomFiltersAnd CustomFilter
    f1 CustomFilter
    f2
                    else FilterColumn -> Either Text FilterColumn
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (FilterColumn -> Either Text FilterColumn)
    -> FilterColumn -> Either Text FilterColumn
    forall a b. (a -> b) -> a -> b
    $ CustomFilter -> CustomFilter -> FilterColumn
    CustomFiltersOr CustomFilter
    f1 CustomFilter
    f2
                [CustomFilter]
    _ ->
                  Text -> Either Text FilterColumn
    forall a b. a -> Either a b
    Left (Text -> Either Text FilterColumn)
    -> Text -> Either Text FilterColumn
    forall a b. (a -> b) -> a -> b
    $
                  Text
    "expected 1 or 2 custom filters but found " Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>
                  [Char] -> Text
    T.pack (Int -> [Char]
    forall a. Show a => a -> [Char]
    show (Int -> [Char]) -> Int -> [Char]
    forall a b. (a -> b) -> a -> b
    $ [CustomFilter] -> Int
    forall a. [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [CustomFilter]
    cfilters)
          dynamic :: ChildCollector FilterColumn
    dynamic =
            ByteString
    -> (Node -> Either Text FilterColumn)
    -> ChildCollector FilterColumn
    forall a. ByteString -> (Node -> Either Text a) -> ChildCollector a
    requireAndParse ByteString
    "dynamicFilter" ((Node -> Either Text FilterColumn) -> ChildCollector FilterColumn)
    -> (AttrParser FilterColumn -> Node -> Either Text FilterColumn)
    -> AttrParser FilterColumn
    -> ChildCollector FilterColumn
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Node -> AttrParser FilterColumn -> Either Text FilterColumn)
    -> AttrParser FilterColumn -> Node -> Either Text FilterColumn
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Node -> AttrParser FilterColumn -> Either Text FilterColumn
    forall a. Node -> AttrParser a -> Either Text a
    parseAttributes (AttrParser FilterColumn -> ChildCollector FilterColumn)
    -> AttrParser FilterColumn -> ChildCollector FilterColumn
    forall a b. (a -> b) -> a -> b
    $ do
              _dfoType <- ByteString -> AttrParser DynFilterType
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "type"
              _dfoVal <- maybeAttr "val"
              _dfoMaxVal <- maybeAttr "maxVal"
              return $ DynamicFilter DynFilterOptions {..}
          icon :: ChildCollector FilterColumn
    icon =
            ByteString
    -> (Node -> Either Text FilterColumn)
    -> ChildCollector FilterColumn
    forall a. ByteString -> (Node -> Either Text a) -> ChildCollector a
    requireAndParse ByteString
    "iconFilter" ((Node -> Either Text FilterColumn) -> ChildCollector FilterColumn)
    -> (AttrParser FilterColumn -> Node -> Either Text FilterColumn)
    -> AttrParser FilterColumn
    -> ChildCollector FilterColumn
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Node -> AttrParser FilterColumn -> Either Text FilterColumn)
    -> AttrParser FilterColumn -> Node -> Either Text FilterColumn
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Node -> AttrParser FilterColumn -> Either Text FilterColumn
    forall a. Node -> AttrParser a -> Either Text a
    parseAttributes (AttrParser FilterColumn -> ChildCollector FilterColumn)
    -> AttrParser FilterColumn -> ChildCollector FilterColumn
    forall a b. (a -> b) -> a -> b
    $
            Maybe Int -> IconSetType -> FilterColumn
    IconFilter (Maybe Int -> IconSetType -> FilterColumn)
    -> AttrParser (Maybe Int)
    -> AttrParser (IconSetType -> FilterColumn)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ByteString -> AttrParser (Maybe Int)
    forall a. FromAttrBs a => ByteString -> AttrParser (Maybe a)
    maybeAttr ByteString
    "iconId" AttrParser (IconSetType -> FilterColumn)
    -> AttrParser IconSetType -> AttrParser FilterColumn
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser IconSetType
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "iconSet"
          top10 :: ChildCollector FilterColumn
    top10 =
            ByteString
    -> (Node -> Either Text FilterColumn)
    -> ChildCollector FilterColumn
    forall a. ByteString -> (Node -> Either Text a) -> ChildCollector a
    requireAndParse ByteString
    "top10" ((Node -> Either Text FilterColumn) -> ChildCollector FilterColumn)
    -> (AttrParser FilterColumn -> Node -> Either Text FilterColumn)
    -> AttrParser FilterColumn
    -> ChildCollector FilterColumn
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Node -> AttrParser FilterColumn -> Either Text FilterColumn)
    -> AttrParser FilterColumn -> Node -> Either Text FilterColumn
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Node -> AttrParser FilterColumn -> Either Text FilterColumn
    forall a. Node -> AttrParser a -> Either Text a
    parseAttributes (AttrParser FilterColumn -> ChildCollector FilterColumn)
    -> AttrParser FilterColumn -> ChildCollector FilterColumn
    forall a b. (a -> b) -> a -> b
    $ do
              top <- ByteString -> Bool -> AttrParser Bool
    forall a. FromAttrBs a => ByteString -> a -> AttrParser a
    fromAttrDef ByteString
    "top" Bool
    True
              percent <- fromAttrDef "percent" False
              val <- fromAttr "val"
              filterVal <- maybeAttr "filterVal"
              let opts = Bool -> Double -> Maybe Double -> EdgeFilterOptions
    EdgeFilterOptions Bool
    percent Double
    val Maybe Double
    filterVal
              if top
                then return $ TopNFilter opts
                else return $ BottomNFilter opts

    instance FromXenoNode CustomFilter where
      fromXenoNode :: Node -> Either Text CustomFilter
    fromXenoNode Node
    root =
        Node -> AttrParser CustomFilter -> Either Text CustomFilter
    forall a. Node -> AttrParser a -> Either Text a
    parseAttributes Node
    root (AttrParser CustomFilter -> Either Text CustomFilter)
    -> AttrParser CustomFilter -> Either Text CustomFilter
    forall a b. (a -> b) -> a -> b
    $
        CustomFilterOperator -> Text -> CustomFilter
    CustomFilter (CustomFilterOperator -> Text -> CustomFilter)
    -> AttrParser CustomFilterOperator
    -> AttrParser (Text -> CustomFilter)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ByteString
    -> CustomFilterOperator -> AttrParser CustomFilterOperator
    forall a. FromAttrBs a => ByteString -> a -> AttrParser a
    fromAttrDef ByteString
    "operator" CustomFilterOperator
    FltrEqual AttrParser (Text -> CustomFilter)
    -> AttrParser Text -> AttrParser CustomFilter
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Text
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "val"

    fltColFromNode :: Node -> [FilterColumn]
    fltColFromNode :: Node -> [FilterColumn]
    fltColFromNode Node
    n | Node
    n Node -> Name -> Bool
    `nodeElNameIs` (Text -> Name
    n_ Text
    "filters") = do
                         let filterCriteria :: [FilterCriterion]
    filterCriteria = Cursor
    cur Cursor -> (Cursor -> [FilterCriterion]) -> [FilterCriterion]
    forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
    $/ Axis
    anyElement Axis
    -> (Cursor -> [FilterCriterion]) -> Cursor -> [FilterCriterion]
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> Cursor -> [FilterCriterion]
    forall a. FromCursor a => Cursor -> [a]
    fromCursor
                         filterBlank <- Name -> FilterByBlank -> Cursor -> [FilterByBlank]
    forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
    fromAttributeDef Name
    "blank" FilterByBlank
    DontFilterByBlank Cursor
    cur
                         return $ Filters filterBlank filterCriteria
                     | Node
    n Node -> Name -> Bool
    `nodeElNameIs` (Text -> Name
    n_ Text
    "colorFilter") = do
                         _cfoCellColor <- Name -> Bool -> Cursor -> [Bool]
    forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
    fromAttributeDef Name
    "cellColor" Bool
    True Cursor
    cur
                         _cfoDxfId <- maybeAttribute "dxfId" cur
                         return $ ColorFilter ColorFilterOptions {..}
                     | Node
    n Node -> Name -> Bool
    `nodeElNameIs` (Text -> Name
    n_ Text
    "customFilters") = do
                         isAnd <- Name -> Bool -> Cursor -> [Bool]
    forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
    fromAttributeDef Name
    "and" Bool
    False Cursor
    cur
                         let cFilters = Cursor
    cur Cursor -> (Cursor -> [CustomFilter]) -> [CustomFilter]
    forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
    $/ Name -> Axis
    element (Text -> Name
    n_ Text
    "customFilter") Axis -> (Cursor -> [CustomFilter]) -> Cursor -> [CustomFilter]
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> \Cursor
    c -> do
                               op <- Name -> CustomFilterOperator -> Cursor -> [CustomFilterOperator]
    forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
    fromAttributeDef Name
    "operator" CustomFilterOperator
    FltrEqual Cursor
    c
                               val <- fromAttribute "val" c
                               return $ CustomFilter op val
                         case cFilters of
                           [CustomFilter
    f] ->
                             FilterColumn -> [FilterColumn]
    forall a. a -> [a]
    forall (m :: * -> *) a. Monad m => a -> m a
    return (FilterColumn -> [FilterColumn]) -> FilterColumn -> [FilterColumn]
    forall a b. (a -> b) -> a -> b
    $ CustomFilter -> FilterColumn
    ACustomFilter CustomFilter
    f
                           [CustomFilter
    f1, CustomFilter
    f2] ->
                             if Bool
    isAnd
                               then FilterColumn -> [FilterColumn]
    forall a. a -> [a]
    forall (m :: * -> *) a. Monad m => a -> m a
    return (FilterColumn -> [FilterColumn]) -> FilterColumn -> [FilterColumn]
    forall a b. (a -> b) -> a -> b
    $ CustomFilter -> CustomFilter -> FilterColumn
    CustomFiltersAnd CustomFilter
    f1 CustomFilter
    f2
                               else FilterColumn -> [FilterColumn]
    forall a. a -> [a]
    forall (m :: * -> *) a. Monad m => a -> m a
    return (FilterColumn -> [FilterColumn]) -> FilterColumn -> [FilterColumn]
    forall a b. (a -> b) -> a -> b
    $ CustomFilter -> CustomFilter -> FilterColumn
    CustomFiltersOr CustomFilter
    f1 CustomFilter
    f2
                           [CustomFilter]
    _ ->
                             [Char] -> [FilterColumn]
    forall a. [Char] -> [a]
    forall (m :: * -> *) a. MonadFail m => [Char] -> m a
    fail [Char]
    "bad custom filter"
                     | Node
    n Node -> Name -> Bool
    `nodeElNameIs` (Text -> Name
    n_ Text
    "dynamicFilter") = do
                         _dfoType <- Name -> Cursor -> [DynFilterType]
    forall a. FromAttrVal a => Name -> Cursor -> [a]
    fromAttribute Name
    "type" Cursor
    cur
                         _dfoVal <- maybeAttribute "val" cur
                         _dfoMaxVal <- maybeAttribute "maxVal" cur
                         return $ DynamicFilter DynFilterOptions{..}
                     | Node
    n Node -> Name -> Bool
    `nodeElNameIs` (Text -> Name
    n_ Text
    "iconFilter") = do
                         iconId <- Name -> Cursor -> [Maybe Int]
    forall a. FromAttrVal a => Name -> Cursor -> [Maybe a]
    maybeAttribute Name
    "iconId" Cursor
    cur
                         iconSet <- fromAttribute "iconSet" cur
                         return $ IconFilter iconId iconSet
                     | Node
    n Node -> Name -> Bool
    `nodeElNameIs` (Text -> Name
    n_ Text
    "top10") = do
                         top <- Name -> Bool -> Cursor -> [Bool]
    forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
    fromAttributeDef Name
    "top" Bool
    True Cursor
    cur
                         let percent = Name -> Bool -> Cursor -> [Bool]
    forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
    fromAttributeDef Name
    "percent" Bool
    False Cursor
    cur
                             val = Name -> Cursor -> [Double]
    forall a. FromAttrVal a => Name -> Cursor -> [a]
    fromAttribute Name
    "val" Cursor
    cur
                             filterVal = Name -> Cursor -> [Maybe Double]
    forall a. FromAttrVal a => Name -> Cursor -> [Maybe a]
    maybeAttribute Name
    "filterVal" Cursor
    cur
                         if top
                           then fmap TopNFilter $
                                EdgeFilterOptions <$> percent <*> val <*> filterVal
                           else fmap BottomNFilter $
                                EdgeFilterOptions <$> percent <*> val <*> filterVal
                     | Bool
    otherwise = [Char] -> [FilterColumn]
    forall a. [Char] -> [a]
    forall (m :: * -> *) a. MonadFail m => [Char] -> m a
    fail [Char]
    "no matching nodes"
      where
        cur :: Cursor
    cur = Node -> Cursor
    fromNode Node
    n

    instance FromCursor FilterCriterion where
      fromCursor :: Cursor -> [FilterCriterion]
    fromCursor = Node -> [FilterCriterion]
    filterCriterionFromNode (Node -> [FilterCriterion])
    -> (Cursor -> Node) -> Cursor -> [FilterCriterion]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Cursor -> Node
    forall node. Cursor node -> node
    node

    instance FromXenoNode FilterCriterion where
      fromXenoNode :: Node -> Either Text FilterCriterion
    fromXenoNode Node
    root =
        case Node -> ByteString
    Xeno.name Node
    root of
          ByteString
    "filter" -> Node -> AttrParser FilterCriterion -> Either Text FilterCriterion
    forall a. Node -> AttrParser a -> Either Text a
    parseAttributes Node
    root (AttrParser FilterCriterion -> Either Text FilterCriterion)
    -> AttrParser FilterCriterion -> Either Text FilterCriterion
    forall a b. (a -> b) -> a -> b
    $ do Text -> FilterCriterion
    FilterValue (Text -> FilterCriterion)
    -> AttrParser Text -> AttrParser FilterCriterion
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ByteString -> AttrParser Text
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "val"
          ByteString
    "dateGroupItem" ->
            Node -> AttrParser FilterCriterion -> Either Text FilterCriterion
    forall a. Node -> AttrParser a -> Either Text a
    parseAttributes Node
    root (AttrParser FilterCriterion -> Either Text FilterCriterion)
    -> AttrParser FilterCriterion -> Either Text FilterCriterion
    forall a b. (a -> b) -> a -> b
    $ do
              grouping <- ByteString -> AttrParser ByteString
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "dateTimeGrouping"
              group <- case grouping of
                (ByteString
    "year" :: ByteString) ->
                  Int -> DateGroup
    DateGroupByYear (Int -> DateGroup) -> AttrParser Int -> AttrParser DateGroup
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "year"
                ByteString
    "month" ->
                  Int -> Int -> DateGroup
    DateGroupByMonth (Int -> Int -> DateGroup)
    -> AttrParser Int -> AttrParser (Int -> DateGroup)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "year"
                                   AttrParser (Int -> DateGroup)
    -> AttrParser Int -> AttrParser DateGroup
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "month"
                ByteString
    "day" ->
                  Int -> Int -> Int -> DateGroup
    DateGroupByDay (Int -> Int -> Int -> DateGroup)
    -> AttrParser Int -> AttrParser (Int -> Int -> DateGroup)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "year"
                                 AttrParser (Int -> Int -> DateGroup)
    -> AttrParser Int -> AttrParser (Int -> DateGroup)
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "month"
                                 AttrParser (Int -> DateGroup)
    -> AttrParser Int -> AttrParser DateGroup
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "day"
                ByteString
    "hour" ->
                  Int -> Int -> Int -> Int -> DateGroup
    DateGroupByHour (Int -> Int -> Int -> Int -> DateGroup)
    -> AttrParser Int -> AttrParser (Int -> Int -> Int -> DateGroup)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "year"
                                  AttrParser (Int -> Int -> Int -> DateGroup)
    -> AttrParser Int -> AttrParser (Int -> Int -> DateGroup)
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "month"
                                  AttrParser (Int -> Int -> DateGroup)
    -> AttrParser Int -> AttrParser (Int -> DateGroup)
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "day"
                                  AttrParser (Int -> DateGroup)
    -> AttrParser Int -> AttrParser DateGroup
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "hour"
                ByteString
    "minute" ->
                  Int -> Int -> Int -> Int -> Int -> DateGroup
    DateGroupByMinute (Int -> Int -> Int -> Int -> Int -> DateGroup)
    -> AttrParser Int
    -> AttrParser (Int -> Int -> Int -> Int -> DateGroup)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "year"
                                    AttrParser (Int -> Int -> Int -> Int -> DateGroup)
    -> AttrParser Int -> AttrParser (Int -> Int -> Int -> DateGroup)
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "month"
                                    AttrParser (Int -> Int -> Int -> DateGroup)
    -> AttrParser Int -> AttrParser (Int -> Int -> DateGroup)
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "day"
                                    AttrParser (Int -> Int -> DateGroup)
    -> AttrParser Int -> AttrParser (Int -> DateGroup)
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "hour"
                                    AttrParser (Int -> DateGroup)
    -> AttrParser Int -> AttrParser DateGroup
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "minute"
                ByteString
    "second" ->
                  Int -> Int -> Int -> Int -> Int -> Int -> DateGroup
    DateGroupBySecond (Int -> Int -> Int -> Int -> Int -> Int -> DateGroup)
    -> AttrParser Int
    -> AttrParser (Int -> Int -> Int -> Int -> Int -> DateGroup)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "year"
                                    AttrParser (Int -> Int -> Int -> Int -> Int -> DateGroup)
    -> AttrParser Int
    -> AttrParser (Int -> Int -> Int -> Int -> DateGroup)
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "month"
                                    AttrParser (Int -> Int -> Int -> Int -> DateGroup)
    -> AttrParser Int -> AttrParser (Int -> Int -> Int -> DateGroup)
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "day"
                                    AttrParser (Int -> Int -> Int -> DateGroup)
    -> AttrParser Int -> AttrParser (Int -> Int -> DateGroup)
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "hour"
                                    AttrParser (Int -> Int -> DateGroup)
    -> AttrParser Int -> AttrParser (Int -> DateGroup)
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "minute"
                                    AttrParser (Int -> DateGroup)
    -> AttrParser Int -> AttrParser DateGroup
    forall a b. AttrParser (a -> b) -> AttrParser a -> AttrParser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ByteString -> AttrParser Int
    forall a. FromAttrBs a => ByteString -> AttrParser a
    fromAttr ByteString
    "second"
                ByteString
    _ -> Either Text DateGroup -> AttrParser DateGroup
    forall a. Either Text a -> AttrParser a
    toAttrParser (Either Text DateGroup -> AttrParser DateGroup)
    -> (Text -> Either Text DateGroup) -> Text -> AttrParser DateGroup
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Either Text DateGroup
    forall a b. a -> Either a b
    Left (Text -> AttrParser DateGroup) -> Text -> AttrParser DateGroup
    forall a b. (a -> b) -> a -> b
    $ Text
    "Unexpected date grouping"
              return $ FilterDateGroup group
          ByteString
    _ -> Text -> Either Text FilterCriterion
    forall a b. a -> Either a b
    Left Text
    "Bad FilterCriterion"

    -- TODO: follow the spec about the fact that dategroupitem always go after filter
    filterCriterionFromNode :: Node -> [FilterCriterion]
    filterCriterionFromNode :: Node -> [FilterCriterion]
    filterCriterionFromNode Node
    n
      | Node
    n Node -> Name -> Bool
    `nodeElNameIs` (Text -> Name
    n_ Text
    "filter") = do
        v <- Name -> Cursor -> [Text]
    forall a. FromAttrVal a => Name -> Cursor -> [a]
    fromAttribute Name
    "val" Cursor
    cur
        return $ FilterValue v
      | Node
    n Node -> Name -> Bool
    `nodeElNameIs` (Text -> Name
    n_ Text
    "dateGroupItem") = do
        g <- Name -> Cursor -> [Text]
    forall a. FromAttrVal a => Name -> Cursor -> [a]
    fromAttribute Name
    "dateTimeGrouping" Cursor
    cur
        let year = Name -> Cursor -> [Int]
    forall a. FromAttrVal a => Name -> Cursor -> [a]
    fromAttribute Name
    "year" Cursor
    cur
            month = Name -> Cursor -> [Int]
    forall a. FromAttrVal a => Name -> Cursor -> [a]
    fromAttribute Name
    "month" Cursor
    cur
            day = Name -> Cursor -> [Int]
    forall a. FromAttrVal a => Name -> Cursor -> [a]
    fromAttribute Name
    "day" Cursor
    cur
            hour = Name -> Cursor -> [Int]
    forall a. FromAttrVal a => Name -> Cursor -> [a]
    fromAttribute Name
    "hour" Cursor
    cur
            minute = Name -> Cursor -> [Int]
    forall a. FromAttrVal a => Name -> Cursor -> [a]
    fromAttribute Name
    "minute" Cursor
    cur
            second = Name -> Cursor -> [Int]
    forall a. FromAttrVal a => Name -> Cursor -> [a]
    fromAttribute Name
    "second" Cursor
    cur
        FilterDateGroup <$>
          case g of
            Text
    "year" -> Int -> DateGroup
    DateGroupByYear (Int -> DateGroup) -> [Int] -> [DateGroup]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Int]
    year
            Text
    "month" -> Int -> Int -> DateGroup
    DateGroupByMonth (Int -> Int -> DateGroup) -> [Int] -> [Int -> DateGroup]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Int]
    year [Int -> DateGroup] -> [Int] -> [DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Int]
    month
            Text
    "day" -> Int -> Int -> Int -> DateGroup
    DateGroupByDay (Int -> Int -> Int -> DateGroup)
    -> [Int] -> [Int -> Int -> DateGroup]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Int]
    year [Int -> Int -> DateGroup] -> [Int] -> [Int -> DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Int]
    month [Int -> DateGroup] -> [Int] -> [DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Int]
    day
            Text
    "hour" -> Int -> Int -> Int -> Int -> DateGroup
    DateGroupByHour (Int -> Int -> Int -> Int -> DateGroup)
    -> [Int] -> [Int -> Int -> Int -> DateGroup]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Int]
    year [Int -> Int -> Int -> DateGroup]
    -> [Int] -> [Int -> Int -> DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Int]
    month [Int -> Int -> DateGroup] -> [Int] -> [Int -> DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Int]
    day [Int -> DateGroup] -> [Int] -> [DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Int]
    hour
            Text
    "minute" ->
              Int -> Int -> Int -> Int -> Int -> DateGroup
    DateGroupByMinute (Int -> Int -> Int -> Int -> Int -> DateGroup)
    -> [Int] -> [Int -> Int -> Int -> Int -> DateGroup]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Int]
    year [Int -> Int -> Int -> Int -> DateGroup]
    -> [Int] -> [Int -> Int -> Int -> DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Int]
    month [Int -> Int -> Int -> DateGroup]
    -> [Int] -> [Int -> Int -> DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Int]
    day [Int -> Int -> DateGroup] -> [Int] -> [Int -> DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Int]
    hour [Int -> DateGroup] -> [Int] -> [DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Int]
    minute
            Text
    "second" ->
              Int -> Int -> Int -> Int -> Int -> Int -> DateGroup
    DateGroupBySecond (Int -> Int -> Int -> Int -> Int -> Int -> DateGroup)
    -> [Int] -> [Int -> Int -> Int -> Int -> Int -> DateGroup]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Int]
    year [Int -> Int -> Int -> Int -> Int -> DateGroup]
    -> [Int] -> [Int -> Int -> Int -> Int -> DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Int]
    month [Int -> Int -> Int -> Int -> DateGroup]
    -> [Int] -> [Int -> Int -> Int -> DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Int]
    day [Int -> Int -> Int -> DateGroup]
    -> [Int] -> [Int -> Int -> DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Int]
    hour [Int -> Int -> DateGroup] -> [Int] -> [Int -> DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Int]
    minute [Int -> DateGroup] -> [Int] -> [DateGroup]
    forall a b. [a -> b] -> [a] -> [b]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*>
              [Int]
    second
            Text
    _ -> [Char] -> [DateGroup]
    forall a. [Char] -> [a]
    forall (m :: * -> *) a. MonadFail m => [Char] -> m a
    fail ([Char] -> [DateGroup]) -> [Char] -> [DateGroup]
    forall a b. (a -> b) -> a -> b
    $ [Char]
    "unexpected dateTimeGrouping " [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Text -> [Char]
    forall a. Show a => a -> [Char]
    show (Text
    g :: Text)
      | Bool
    otherwise = [Char] -> [FilterCriterion]
    forall a. [Char] -> [a]
    forall (m :: * -> *) a. MonadFail m => [Char] -> m a
    fail [Char]
    "no matching nodes"
      where
        cur :: Cursor
    cur = Node -> Cursor
    fromNode Node
    n

    instance FromAttrVal CustomFilterOperator where
      fromAttrVal :: Reader CustomFilterOperator
    fromAttrVal Text
    "equal" = CustomFilterOperator -> Either [Char] (CustomFilterOperator, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess CustomFilterOperator
    FltrEqual
      fromAttrVal Text
    "greaterThan" = CustomFilterOperator -> Either [Char] (CustomFilterOperator, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess CustomFilterOperator
    FltrGreaterThan
      fromAttrVal Text
    "greaterThanOrEqual" = CustomFilterOperator -> Either [Char] (CustomFilterOperator, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess CustomFilterOperator
    FltrGreaterThanOrEqual
      fromAttrVal Text
    "lessThan" = CustomFilterOperator -> Either [Char] (CustomFilterOperator, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess CustomFilterOperator
    FltrLessThan
      fromAttrVal Text
    "lessThanOrEqual" = CustomFilterOperator -> Either [Char] (CustomFilterOperator, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess CustomFilterOperator
    FltrLessThanOrEqual
      fromAttrVal Text
    "notEqual" = CustomFilterOperator -> Either [Char] (CustomFilterOperator, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess CustomFilterOperator
    FltrNotEqual
      fromAttrVal Text
    t = Text -> Reader CustomFilterOperator
    forall a. Text -> Text -> Either [Char] (a, Text)
    invalidText Text
    "CustomFilterOperator" Text
    t

    instance FromAttrBs CustomFilterOperator where
      fromAttrBs :: ByteString -> Either Text CustomFilterOperator
    fromAttrBs ByteString
    "equal" = CustomFilterOperator -> Either Text CustomFilterOperator
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return CustomFilterOperator
    FltrEqual
      fromAttrBs ByteString
    "greaterThan" = CustomFilterOperator -> Either Text CustomFilterOperator
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return CustomFilterOperator
    FltrGreaterThan
      fromAttrBs ByteString
    "greaterThanOrEqual" = CustomFilterOperator -> Either Text CustomFilterOperator
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return CustomFilterOperator
    FltrGreaterThanOrEqual
      fromAttrBs ByteString
    "lessThan" = CustomFilterOperator -> Either Text CustomFilterOperator
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return CustomFilterOperator
    FltrLessThan
      fromAttrBs ByteString
    "lessThanOrEqual" = CustomFilterOperator -> Either Text CustomFilterOperator
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return CustomFilterOperator
    FltrLessThanOrEqual
      fromAttrBs ByteString
    "notEqual" = CustomFilterOperator -> Either Text CustomFilterOperator
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return CustomFilterOperator
    FltrNotEqual
      fromAttrBs ByteString
    x = Text -> ByteString -> Either Text CustomFilterOperator
    forall a. Text -> ByteString -> Either Text a
    unexpectedAttrBs Text
    "CustomFilterOperator" ByteString
    x

    instance FromAttrVal FilterByBlank where
      fromAttrVal :: Reader FilterByBlank
    fromAttrVal =
        ((Bool, Text) -> (FilterByBlank, Text))
    -> Either [Char] (Bool, Text)
    -> Either [Char] (FilterByBlank, Text)
    forall a b. (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((Bool -> FilterByBlank) -> (Bool, Text) -> (FilterByBlank, 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 -> FilterByBlank) -> (Bool, Text) -> (FilterByBlank, Text))
    -> (Bool -> FilterByBlank) -> (Bool, Text) -> (FilterByBlank, Text)
    forall a b. (a -> b) -> a -> b
    $ FilterByBlank -> FilterByBlank -> Bool -> FilterByBlank
    forall a. a -> a -> Bool -> a
    bool FilterByBlank
    DontFilterByBlank FilterByBlank
    FilterByBlank) (Either [Char] (Bool, Text) -> Either [Char] (FilterByBlank, Text))
    -> (Text -> Either [Char] (Bool, Text)) -> Reader FilterByBlank
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Either [Char] (Bool, Text)
    forall a. FromAttrVal a => Reader a
    fromAttrVal

    instance FromAttrBs FilterByBlank where
      fromAttrBs :: ByteString -> Either Text FilterByBlank
    fromAttrBs = (Bool -> FilterByBlank)
    -> Either Text Bool -> Either Text FilterByBlank
    forall a b. (a -> b) -> Either Text a -> Either Text b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (FilterByBlank -> FilterByBlank -> Bool -> FilterByBlank
    forall a. a -> a -> Bool -> a
    bool FilterByBlank
    DontFilterByBlank FilterByBlank
    FilterByBlank) (Either Text Bool -> Either Text FilterByBlank)
    -> (ByteString -> Either Text Bool)
    -> ByteString
    -> Either Text FilterByBlank
    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 DynFilterType where
      fromAttrVal :: Reader DynFilterType
    fromAttrVal Text
    "aboveAverage" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterAboveAverage
      fromAttrVal Text
    "belowAverage" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterBelowAverage
      fromAttrVal Text
    "lastMonth" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterLastMonth
      fromAttrVal Text
    "lastQuarter" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterLastQuarter
      fromAttrVal Text
    "lastWeek" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterLastWeek
      fromAttrVal Text
    "lastYear" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterLastYear
      fromAttrVal Text
    "M1" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterM1
      fromAttrVal Text
    "M10" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterM10
      fromAttrVal Text
    "M11" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterM11
      fromAttrVal Text
    "M12" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterM12
      fromAttrVal Text
    "M2" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterM2
      fromAttrVal Text
    "M3" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterM3
      fromAttrVal Text
    "M4" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterM4
      fromAttrVal Text
    "M5" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterM5
      fromAttrVal Text
    "M6" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterM6
      fromAttrVal Text
    "M7" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterM7
      fromAttrVal Text
    "M8" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterM8
      fromAttrVal Text
    "M9" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterM9
      fromAttrVal Text
    "nextMonth" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterNextMonth
      fromAttrVal Text
    "nextQuarter" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterNextQuarter
      fromAttrVal Text
    "nextWeek" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterNextWeek
      fromAttrVal Text
    "nextYear" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterNextYear
      fromAttrVal Text
    "null" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterNull
      fromAttrVal Text
    "Q1" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterQ1
      fromAttrVal Text
    "Q2" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterQ2
      fromAttrVal Text
    "Q3" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterQ3
      fromAttrVal Text
    "Q4" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterQ4
      fromAttrVal Text
    "thisMonth" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterThisMonth
      fromAttrVal Text
    "thisQuarter" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterThisQuarter
      fromAttrVal Text
    "thisWeek" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterThisWeek
      fromAttrVal Text
    "thisYear" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterThisYear
      fromAttrVal Text
    "today" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterToday
      fromAttrVal Text
    "tomorrow" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterTomorrow
      fromAttrVal Text
    "yearToDate" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterYearToDate
      fromAttrVal Text
    "yesterday" = DynFilterType -> Either [Char] (DynFilterType, Text)
    forall a. a -> Either [Char] (a, Text)
    readSuccess DynFilterType
    DynFilterYesterday
      fromAttrVal Text
    t = Text -> Reader DynFilterType
    forall a. Text -> Text -> Either [Char] (a, Text)
    invalidText Text
    "DynFilterType" Text
    t

    instance FromAttrBs DynFilterType where
      fromAttrBs :: ByteString -> Either Text DynFilterType
    fromAttrBs ByteString
    "aboveAverage" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterAboveAverage
      fromAttrBs ByteString
    "belowAverage" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterBelowAverage
      fromAttrBs ByteString
    "lastMonth" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterLastMonth
      fromAttrBs ByteString
    "lastQuarter" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterLastQuarter
      fromAttrBs ByteString
    "lastWeek" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterLastWeek
      fromAttrBs ByteString
    "lastYear" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterLastYear
      fromAttrBs ByteString
    "M1" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterM1
      fromAttrBs ByteString
    "M10" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterM10
      fromAttrBs ByteString
    "M11" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterM11
      fromAttrBs ByteString
    "M12" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterM12
      fromAttrBs ByteString
    "M2" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterM2
      fromAttrBs ByteString
    "M3" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterM3
      fromAttrBs ByteString
    "M4" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterM4
      fromAttrBs ByteString
    "M5" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterM5
      fromAttrBs ByteString
    "M6" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterM6
      fromAttrBs ByteString
    "M7" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterM7
      fromAttrBs ByteString
    "M8" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterM8
      fromAttrBs ByteString
    "M9" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterM9
      fromAttrBs ByteString
    "nextMonth" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterNextMonth
      fromAttrBs ByteString
    "nextQuarter" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterNextQuarter
      fromAttrBs ByteString
    "nextWeek" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterNextWeek
      fromAttrBs ByteString
    "nextYear" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterNextYear
      fromAttrBs ByteString
    "null" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterNull
      fromAttrBs ByteString
    "Q1" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterQ1
      fromAttrBs ByteString
    "Q2" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterQ2
      fromAttrBs ByteString
    "Q3" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterQ3
      fromAttrBs ByteString
    "Q4" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterQ4
      fromAttrBs ByteString
    "thisMonth" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterThisMonth
      fromAttrBs ByteString
    "thisQuarter" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterThisQuarter
      fromAttrBs ByteString
    "thisWeek" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterThisWeek
      fromAttrBs ByteString
    "thisYear" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterThisYear
      fromAttrBs ByteString
    "today" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterToday
      fromAttrBs ByteString
    "tomorrow" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterTomorrow
      fromAttrBs ByteString
    "yearToDate" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterYearToDate
      fromAttrBs ByteString
    "yesterday" = DynFilterType -> Either Text DynFilterType
    forall a. a -> Either Text a
    forall (m :: * -> *) a. Monad m => a -> m a
    return DynFilterType
    DynFilterYesterday
      fromAttrBs ByteString
    x = Text -> ByteString -> Either Text DynFilterType
    forall a. Text -> ByteString -> Either Text a
    unexpectedAttrBs Text
    "DynFilterType" ByteString
    x

    {-------------------------------------------------------------------------------
      Rendering
    -------------------------------------------------------------------------------}

    instance ToElement AutoFilter where
      toElement :: Name -> AutoFilter -> Element
    toElement Name
    nm AutoFilter {Maybe CellRef
    Map Int FilterColumn
    _afRef :: AutoFilter -> Maybe CellRef
    _afFilterColumns :: AutoFilter -> Map Int FilterColumn
    _afRef :: Maybe CellRef
    _afFilterColumns :: Map Int FilterColumn
    ..} =
        Name -> [(Name, Text)] -> [Element] -> Element
    elementList
          Name
    nm
          ([Maybe (Name, Text)] -> [(Name, Text)]
    forall a. [Maybe a] -> [a]
    catMaybes [Name
    "ref" Name -> Maybe CellRef -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? Maybe CellRef
    _afRef])
          [ Name -> [(Name, Text)] -> [Element] -> Element
    elementList
            (Text -> Name
    n_ Text
    "filterColumn")
            [Name
    "colId" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    colId]
            [FilterColumn -> Element
    fltColToElement FilterColumn
    fCol]
          | (Int
    colId, FilterColumn
    fCol) <- Map Int FilterColumn -> [(Int, FilterColumn)]
    forall k a. Map k a -> [(k, a)]
    M.toList Map Int FilterColumn
    _afFilterColumns
          ]

    fltColToElement :: FilterColumn -> Element
    fltColToElement :: FilterColumn -> Element
    fltColToElement (Filters FilterByBlank
    filterBlank [FilterCriterion]
    filterCriteria) =
      let attrs :: [(Name, Text)]
    attrs = [Maybe (Name, Text)] -> [(Name, Text)]
    forall a. [Maybe a] -> [a]
    catMaybes [Name
    "blank" Name -> Maybe FilterByBlank -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? FilterByBlank -> FilterByBlank -> Maybe FilterByBlank
    forall a. Eq a => a -> a -> Maybe a
    justNonDef FilterByBlank
    DontFilterByBlank FilterByBlank
    filterBlank]
      in Name -> [(Name, Text)] -> [Element] -> Element
    elementList
         (Text -> Name
    n_ Text
    "filters") [(Name, Text)]
    attrs ([Element] -> Element) -> [Element] -> Element
    forall a b. (a -> b) -> a -> b
    $ (FilterCriterion -> Element) -> [FilterCriterion] -> [Element]
    forall a b. (a -> b) -> [a] -> [b]
    map FilterCriterion -> Element
    filterCriterionToElement [FilterCriterion]
    filterCriteria
    fltColToElement (ColorFilter ColorFilterOptions
    opts) = Name -> ColorFilterOptions -> Element
    forall a. ToElement a => Name -> a -> Element
    toElement (Text -> Name
    n_ Text
    "colorFilter") ColorFilterOptions
    opts
    fltColToElement (ACustomFilter CustomFilter
    f) =
      Name -> [Element] -> Element
    elementListSimple (Text -> Name
    n_ Text
    "customFilters") [Name -> CustomFilter -> Element
    forall a. ToElement a => Name -> a -> Element
    toElement (Text -> Name
    n_ Text
    "customFilter") CustomFilter
    f]
    fltColToElement (CustomFiltersOr CustomFilter
    f1 CustomFilter
    f2) =
      Name -> [Element] -> Element
    elementListSimple
        (Text -> Name
    n_ Text
    "customFilters")
        [Name -> CustomFilter -> Element
    forall a. ToElement a => Name -> a -> Element
    toElement (Text -> Name
    n_ Text
    "customFilter") CustomFilter
    f | CustomFilter
    f <- [CustomFilter
    f1, CustomFilter
    f2]]
    fltColToElement (CustomFiltersAnd CustomFilter
    f1 CustomFilter
    f2) =
      Name -> [(Name, Text)] -> [Element] -> Element
    elementList
        (Text -> Name
    n_ Text
    "customFilters")
        [Name
    "and" Name -> Bool -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Bool
    True]
        [Name -> CustomFilter -> Element
    forall a. ToElement a => Name -> a -> Element
    toElement (Text -> Name
    n_ Text
    "customFilter") CustomFilter
    f | CustomFilter
    f <- [CustomFilter
    f1, CustomFilter
    f2]]
    fltColToElement (DynamicFilter DynFilterOptions
    opts) = Name -> DynFilterOptions -> Element
    forall a. ToElement a => Name -> a -> Element
    toElement (Text -> Name
    n_ Text
    "dynamicFilter") DynFilterOptions
    opts
    fltColToElement (IconFilter Maybe Int
    iconId IconSetType
    iconSet) =
      Name -> [(Name, Text)] -> Element
    leafElement (Text -> Name
    n_ Text
    "iconFilter") ([(Name, Text)] -> Element) -> [(Name, Text)] -> Element
    forall a b. (a -> b) -> a -> b
    $
      [Name
    "iconSet" Name -> IconSetType -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= IconSetType
    iconSet] [(Name, Text)] -> [(Name, Text)] -> [(Name, Text)]
    forall a. [a] -> [a] -> [a]
    ++ [Maybe (Name, Text)] -> [(Name, Text)]
    forall a. [Maybe a] -> [a]
    catMaybes [Name
    "iconId" Name -> Maybe Int -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? Maybe Int
    iconId]
    fltColToElement (BottomNFilter EdgeFilterOptions
    opts) = Bool -> EdgeFilterOptions -> Element
    edgeFilter Bool
    False EdgeFilterOptions
    opts
    fltColToElement (TopNFilter EdgeFilterOptions
    opts) = Bool -> EdgeFilterOptions -> Element
    edgeFilter Bool
    True EdgeFilterOptions
    opts

    edgeFilter :: Bool -> EdgeFilterOptions -> Element
    edgeFilter :: Bool -> EdgeFilterOptions -> Element
    edgeFilter Bool
    top EdgeFilterOptions {Bool
    Double
    Maybe Double
    _efoUsePercents :: EdgeFilterOptions -> Bool
    _efoVal :: EdgeFilterOptions -> Double
    _efoFilterVal :: EdgeFilterOptions -> Maybe Double
    _efoUsePercents :: Bool
    _efoVal :: Double
    _efoFilterVal :: Maybe Double
    ..} =
      Name -> [(Name, Text)] -> Element
    leafElement (Text -> Name
    n_ Text
    "top10") ([(Name, Text)] -> Element) -> [(Name, Text)] -> Element
    forall a b. (a -> b) -> a -> b
    $
      [Name
    "top" Name -> Bool -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Bool
    top, Name
    "percent" Name -> Bool -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Bool
    _efoUsePercents, Name
    "val" Name -> Double -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Double
    _efoVal] [(Name, Text)] -> [(Name, Text)] -> [(Name, Text)]
    forall a. [a] -> [a] -> [a]
    ++
      [Maybe (Name, Text)] -> [(Name, Text)]
    forall a. [Maybe a] -> [a]
    catMaybes [Name
    "filterVal" Name -> Maybe Double -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? Maybe Double
    _efoFilterVal]

    filterCriterionToElement :: FilterCriterion -> Element
    filterCriterionToElement :: FilterCriterion -> Element
    filterCriterionToElement (FilterValue Text
    v) =
      Name -> [(Name, Text)] -> Element
    leafElement (Text -> Name
    n_ Text
    "filter") [Name
    "val" Name -> Text -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Text
    v]
    filterCriterionToElement (FilterDateGroup (DateGroupByYear Int
    y)) =
      Name -> [(Name, Text)] -> Element
    leafElement
        (Text -> Name
    n_ Text
    "dateGroupItem")
        [Name
    "dateTimeGrouping" Name -> Text -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= (Text
    "year" :: Text), Name
    "year" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    y]
    filterCriterionToElement (FilterDateGroup (DateGroupByMonth Int
    y Int
    m)) =
      Name -> [(Name, Text)] -> Element
    leafElement
        (Text -> Name
    n_ Text
    "dateGroupItem")
        [Name
    "dateTimeGrouping" Name -> Text -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= (Text
    "month" :: Text), Name
    "year" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    y, Name
    "month" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    m]
    filterCriterionToElement (FilterDateGroup (DateGroupByDay Int
    y Int
    m Int
    d)) =
      Name -> [(Name, Text)] -> Element
    leafElement
        (Text -> Name
    n_ Text
    "dateGroupItem")
        [Name
    "dateTimeGrouping" Name -> Text -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= (Text
    "day" :: Text), Name
    "year" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    y, Name
    "month" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    m, Name
    "day" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    d]
    filterCriterionToElement (FilterDateGroup (DateGroupByHour Int
    y Int
    m Int
    d Int
    h)) =
      Name -> [(Name, Text)] -> Element
    leafElement
        (Text -> Name
    n_ Text
    "dateGroupItem")
        [ Name
    "dateTimeGrouping" Name -> Text -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= (Text
    "hour" :: Text)
        , Name
    "year" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    y
        , Name
    "month" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    m
        , Name
    "day" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    d
        , Name
    "hour" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    h
        ]
    filterCriterionToElement (FilterDateGroup (DateGroupByMinute Int
    y Int
    m Int
    d Int
    h Int
    mi)) =
      Name -> [(Name, Text)] -> Element
    leafElement
        (Text -> Name
    n_ Text
    "dateGroupItem")
        [ Name
    "dateTimeGrouping" Name -> Text -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= (Text
    "minute" :: Text)
        , Name
    "year" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    y
        , Name
    "month" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    m
        , Name
    "day" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    d
        , Name
    "hour" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    h
        , Name
    "minute" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    mi
        ]
    filterCriterionToElement (FilterDateGroup (DateGroupBySecond Int
    y Int
    m Int
    d Int
    h Int
    mi Int
    s)) =
      Name -> [(Name, Text)] -> Element
    leafElement
        (Text -> Name
    n_ Text
    "dateGroupItem")
        [ Name
    "dateTimeGrouping" Name -> Text -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= (Text
    "second" :: Text)
        , Name
    "year" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    y
        , Name
    "month" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    m
        , Name
    "day" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    d
        , Name
    "hour" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    h
        , Name
    "minute" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    mi
        , Name
    "second" Name -> Int -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Int
    s
        ]

    instance ToElement CustomFilter where
      toElement :: Name -> CustomFilter -> Element
    toElement Name
    nm CustomFilter {Text
    CustomFilterOperator
    cfltOperator :: CustomFilter -> CustomFilterOperator
    cfltValue :: CustomFilter -> Text
    cfltOperator :: CustomFilterOperator
    cfltValue :: Text
    ..} =
        Name -> [(Name, Text)] -> Element
    leafElement Name
    nm [Name
    "operator" Name -> CustomFilterOperator -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= CustomFilterOperator
    cfltOperator, Name
    "val" Name -> Text -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Text
    cfltValue]

    instance ToAttrVal CustomFilterOperator where
      toAttrVal :: CustomFilterOperator -> Text
    toAttrVal CustomFilterOperator
    FltrEqual = Text
    "equal"
      toAttrVal CustomFilterOperator
    FltrGreaterThan = Text
    "greaterThan"
      toAttrVal CustomFilterOperator
    FltrGreaterThanOrEqual = Text
    "greaterThanOrEqual"
      toAttrVal CustomFilterOperator
    FltrLessThan = Text
    "lessThan"
      toAttrVal CustomFilterOperator
    FltrLessThanOrEqual = Text
    "lessThanOrEqual"
      toAttrVal CustomFilterOperator
    FltrNotEqual = Text
    "notEqual"

    instance ToAttrVal FilterByBlank where
      toAttrVal :: FilterByBlank -> Text
    toAttrVal FilterByBlank
    FilterByBlank = Bool -> Text
    forall a. ToAttrVal a => a -> Text
    toAttrVal Bool
    True
      toAttrVal FilterByBlank
    DontFilterByBlank = Bool -> Text
    forall a. ToAttrVal a => a -> Text
    toAttrVal Bool
    False

    instance ToElement ColorFilterOptions where
      toElement :: Name -> ColorFilterOptions -> Element
    toElement Name
    nm ColorFilterOptions {Bool
    Maybe Int
    _cfoCellColor :: ColorFilterOptions -> Bool
    _cfoDxfId :: ColorFilterOptions -> Maybe Int
    _cfoCellColor :: Bool
    _cfoDxfId :: Maybe Int
    ..} =
        Name -> [(Name, Text)] -> Element
    leafElement Name
    nm ([(Name, Text)] -> Element) -> [(Name, Text)] -> Element
    forall a b. (a -> b) -> a -> b
    $
        [Maybe (Name, Text)] -> [(Name, Text)]
    forall a. [Maybe a] -> [a]
    catMaybes [Name
    "cellColor" Name -> Maybe Bool -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? Bool -> Maybe Bool
    justFalse Bool
    _cfoCellColor, Name
    "dxfId" Name -> Maybe Int -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? Maybe Int
    _cfoDxfId]

    instance ToElement DynFilterOptions where
      toElement :: Name -> DynFilterOptions -> Element
    toElement Name
    nm DynFilterOptions {Maybe Double
    DynFilterType
    _dfoMaxVal :: DynFilterOptions -> Maybe Double
    _dfoType :: DynFilterOptions -> DynFilterType
    _dfoVal :: DynFilterOptions -> Maybe Double
    _dfoType :: DynFilterType
    _dfoVal :: Maybe Double
    _dfoMaxVal :: Maybe Double
    ..} =
        Name -> [(Name, Text)] -> Element
    leafElement Name
    nm ([(Name, Text)] -> Element) -> [(Name, Text)] -> Element
    forall a b. (a -> b) -> a -> b
    $
        [Name
    "type" Name -> DynFilterType -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= DynFilterType
    _dfoType] [(Name, Text)] -> [(Name, Text)] -> [(Name, Text)]
    forall a. [a] -> [a] -> [a]
    ++
        [Maybe (Name, Text)] -> [(Name, Text)]
    forall a. [Maybe a] -> [a]
    catMaybes [Name
    "val" Name -> Maybe Double -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? Maybe Double
    _dfoVal, Name
    "maxVal" Name -> Maybe Double -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? Maybe Double
    _dfoMaxVal]

    instance ToAttrVal DynFilterType where
      toAttrVal :: DynFilterType -> Text
    toAttrVal DynFilterType
    DynFilterAboveAverage = Text
    "aboveAverage"
      toAttrVal DynFilterType
    DynFilterBelowAverage = Text
    "belowAverage"
      toAttrVal DynFilterType
    DynFilterLastMonth = Text
    "lastMonth"
      toAttrVal DynFilterType
    DynFilterLastQuarter = Text
    "lastQuarter"
      toAttrVal DynFilterType
    DynFilterLastWeek = Text
    "lastWeek"
      toAttrVal DynFilterType
    DynFilterLastYear = Text
    "lastYear"
      toAttrVal DynFilterType
    DynFilterM1 = Text
    "M1"
      toAttrVal DynFilterType
    DynFilterM10 = Text
    "M10"
      toAttrVal DynFilterType
    DynFilterM11 = Text
    "M11"
      toAttrVal DynFilterType
    DynFilterM12 = Text
    "M12"
      toAttrVal DynFilterType
    DynFilterM2 = Text
    "M2"
      toAttrVal DynFilterType
    DynFilterM3 = Text
    "M3"
      toAttrVal DynFilterType
    DynFilterM4 = Text
    "M4"
      toAttrVal DynFilterType
    DynFilterM5 = Text
    "M5"
      toAttrVal DynFilterType
    DynFilterM6 = Text
    "M6"
      toAttrVal DynFilterType
    DynFilterM7 = Text
    "M7"
      toAttrVal DynFilterType
    DynFilterM8 = Text
    "M8"
      toAttrVal DynFilterType
    DynFilterM9 = Text
    "M9"
      toAttrVal DynFilterType
    DynFilterNextMonth = Text
    "nextMonth"
      toAttrVal DynFilterType
    DynFilterNextQuarter = Text
    "nextQuarter"
      toAttrVal DynFilterType
    DynFilterNextWeek = Text
    "nextWeek"
      toAttrVal DynFilterType
    DynFilterNextYear = Text
    "nextYear"
      toAttrVal DynFilterType
    DynFilterNull = Text
    "null"
      toAttrVal DynFilterType
    DynFilterQ1 = Text
    "Q1"
      toAttrVal DynFilterType
    DynFilterQ2 = Text
    "Q2"
      toAttrVal DynFilterType
    DynFilterQ3 = Text
    "Q3"
      toAttrVal DynFilterType
    DynFilterQ4 = Text
    "Q4"
      toAttrVal DynFilterType
    DynFilterThisMonth = Text
    "thisMonth"
      toAttrVal DynFilterType
    DynFilterThisQuarter = Text
    "thisQuarter"
      toAttrVal DynFilterType
    DynFilterThisWeek = Text
    "thisWeek"
      toAttrVal DynFilterType
    DynFilterThisYear = Text
    "thisYear"
      toAttrVal DynFilterType
    DynFilterToday = Text
    "today"
      toAttrVal DynFilterType
    DynFilterTomorrow = Text
    "tomorrow"
      toAttrVal DynFilterType
    DynFilterYearToDate = Text
    "yearToDate"
      toAttrVal DynFilterType
    DynFilterYesterday = Text
    "yesterday"