~alcinnz/haskell-stylist

2881aec48224a437d9a258a44637b7b0746057ae — Adrian Cochrane 5 years ago d47030f
Implement simple facade over the rule stores.

This will later be extended to support cascade and dispatching.
1 files changed, 11 insertions(+), 1 deletions(-)

M src/Stylish/Style/Selector.hs
M src/Stylish/Style/Selector.hs => src/Stylish/Style/Selector.hs +11 -1
@@ 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