1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

Add a TermContainer typeclass.

It’s like a lens, but terrible and ad hoc.
This commit is contained in:
Rob Rix 2015-12-29 09:50:47 -05:00
parent 465b3e5207
commit b738163094

View File

@ -101,6 +101,10 @@ splitDiffByLines diff (prevLeft, prevRight) sources = case diff of
where categories (Info _ left, Info _ right) = (left, right)
ranges (Info left _, Info right _) = (left, right)
class TermContainer a where
toTerm :: a -> Term String Info
setTerm :: a -> Term String Info -> a
-- | Takes a term and a source and returns a list of lines and their range within source.
splitTermByLines :: Eq a => Term a Info -> Source Char -> ([Line (Term a Info)], Range)
splitTermByLines (Info range categories :< syntax) source = flip (,) range $ case syntax of