From e4225faa20054c4e8b5e7677f3e6f6da2f9ff7af Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 23 Dec 2015 23:25:00 -0500 Subject: [PATCH] =?UTF-8?q?Rename=20`subsource`=20=E2=86=92=20`slice`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Source.hs | 4 ++-- src/Split.hs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Source.hs b/src/Source.hs index 944d5e702..0a0a23527 100644 --- a/src/Source.hs +++ b/src/Source.hs @@ -12,8 +12,8 @@ makeSource = Source . Vector.fromList unSource :: Source a -> [a] unSource (Source vector) = Vector.toList vector -subsource :: Range -> Source a -> Source a -subsource range (Source vector) = Source $ Vector.slice (start range) (end range - start range) vector +slice :: Range -> Source a -> Source a +slice range (Source vector) = Source $ Vector.slice (start range) (end range - start range) vector toString :: Source Char -> String toString = unSource diff --git a/src/Split.hs b/src/Split.hs index 1fe0e329c..ea0685372 100644 --- a/src/Split.hs +++ b/src/Split.hs @@ -71,15 +71,15 @@ newtype Renderable a = Renderable (Source Char, a) instance ToMarkup f => ToMarkup (Renderable (Info, Syntax a (f, Range))) where toMarkup (Renderable (source, (Info range categories, syntax))) = classifyMarkup categories $ case syntax of - Leaf _ -> span . string . toString $ subsource range source + Leaf _ -> span . string . toString $ slice range source Indexed children -> ul . mconcat $ contentElements children Fixed children -> ul . mconcat $ contentElements children Keyed children -> dl . mconcat $ contentElements children where markupForSeparatorAndChild :: ToMarkup f => ([Markup], Int) -> (f, Range) -> ([Markup], Int) - markupForSeparatorAndChild (rows, previous) child = (rows ++ [ string (toString $ subsource (Range previous $ start $ snd child) source), toMarkup $ fst child ], end $ snd child) + markupForSeparatorAndChild (rows, previous) child = (rows ++ [ string (toString $ slice (Range previous $ start $ snd child) source), toMarkup $ fst child ], end $ snd child) contentElements children = let (elements, previous) = foldl markupForSeparatorAndChild ([], start range) children in - elements ++ [ string . toString $ subsource (Range previous $ end range) source ] + elements ++ [ string . toString $ slice (Range previous $ end range) source ] instance ToMarkup (Renderable (Term a Info)) where toMarkup (Renderable (source, term)) = fst $ cata (\ info@(Info range _) syntax -> (toMarkup $ Renderable (source, (info, syntax)), range)) term @@ -162,5 +162,5 @@ actualLines source = case Source.break (== '\n') source of -- | Compute the line ranges within a given range of a string. actualLineRanges :: Range -> Source Char -> [Range] -actualLineRanges range = drop 1 . scanl toRange (Range (start range) (start range)) . actualLines . subsource range +actualLineRanges range = drop 1 . scanl toRange (Range (start range) (start range)) . actualLines . slice range where toRange previous string = Range (end previous) $ end previous + length string