From 2881aec48224a437d9a258a44637b7b0746057ae Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Mon, 17 Jun 2019 17:25:00 +1200 Subject: [PATCH] Implement simple facade over the rule stores. This will later be extended to support cascade and dispatching. --- src/Stylish/Style/Selector.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Stylish/Style/Selector.hs b/src/Stylish/Style/Selector.hs index 98b9701..a98877b 100644 --- a/src/Stylish/Style/Selector.hs +++ b/src/Stylish/Style/Selector.hs @@ -1,5 +1,6 @@ module Stylish.Style.Selector( - + QueryableStyleSheet(..), queryableStyleSheet, + queryRules ) where import Stylish.Style.Selector.Index @@ -8,6 +9,8 @@ import Stylish.Style.Selector.Specificity import Stylish.Style.Selector.Importance import Stylish.Style.Selector.Common +import Stylish.Parse (StyleSheet(..)) + ruleStore = ImportanceSplitter $ OrderedRuleStore (InterpretedRuleStore styleIndex) 0 data QueryableStyleSheet store = QueryableStyleSheet { @@ -16,3 +19,10 @@ data QueryableStyleSheet store = QueryableStyleSheet { } queryableStyleSheet = QueryableStyleSheet {store = ruleStore, priority = 0} + +instance RuleStore s => StyleSheet (QueryableStyleSheet s) where + addRule self@(QueryableStyleSheet store priority) rule = self { + store = addStyleRule store priority $ styleRule' rule + } + +queryRules (QueryableStyleSheet store _) el = lookupRules store el -- 2.30.2