--------------------------------------------------------
-- item filtering functions that results in AlterList -- 
--------------------------------------------------------

-- | 
hltFilteredBy_StateT :: (a -> Bool)  -- ^ hit test condition
                     -> [a]          -- ^ strokes to test 
                     -> State Bool (AlterList (NotHitted a) (Hitted a))
hltFilteredBy_StateT test itms = do 
    let (nhit,rest) = break test itms
        (hit,rest') = break (not.test) rest 
    modify (|| (not.null) hit) 
    if null rest' 
      then return (NotHitted nhit :- Hitted hit :- NotHitted [] :- Empty)
      else return (NotHitted nhit :- Hitted hit :- hltFilteredBy test rest')


-- | highlight strokes filtered by a condition. 
--   previously mkHitTestAL
hltFilteredBy_StateT :: (a -> Bool)  -- ^ hit test condition
                     -> [a]          -- ^ strokes to test 
                     -> State Bool (AlterList (NotHitted a) (Hitted a))
hltFilteredBy_StateT test itms = do 
    let (nhit,rest) = break test itms
        (hit,rest') = break (not.test) rest 
    modify (|| (not.null) hit) 
    if null rest' 
      then return (NotHitted nhit :- Hitted hit :- NotHitted [] :- Empty)
      else return (NotHitted nhit :- Hitted hit :- hltFilteredBy test rest')


-- | highlight strokes filtered by a condition. 
--   previously mkHitTestAL
hltFilteredBy_StateT test itms = do 
    let (nhit,rest) = break test itms
        (hit,rest') = break (not.test) rest 
    modify (|| (not.null) hit) 
    if null rest' 
      then return (NotHitted nhit :- Hitted hit :- NotHitted [] :- Empty)
      else return (NotHitted nhit :- Hitted hit :- hltFilteredBy test rest')


-- | highlight strokes filtered by a condition. 
--   previously mkHitTestAL