mirror of
https://github.com/github/semantic.git
synced 2024-12-24 23:42:31 +03:00
Move Source
& its API to the Source
module.
This commit is contained in:
parent
cc9dee5704
commit
e9449fccb8
@ -1,2 +1,21 @@
|
||||
module Source where
|
||||
|
||||
import Range
|
||||
|
||||
newtype Source a = Source (Int, [a])
|
||||
deriving (Eq, Show, Functor, Foldable)
|
||||
|
||||
makeSource :: [a] -> Source a
|
||||
makeSource list = Source (0, list)
|
||||
|
||||
unSource :: Source a -> [a]
|
||||
unSource (Source (_, list)) = list
|
||||
|
||||
subsource :: Range -> Source a -> Source a
|
||||
subsource range (Source (i, list)) = Source (start range, sublist (offsetRange (negate i) range) list)
|
||||
|
||||
toString :: Source Char -> String
|
||||
toString = unSource
|
||||
|
||||
at :: Source a -> Int -> a
|
||||
at = (!!) . unSource
|
||||
|
18
src/Split.hs
18
src/Split.hs
@ -17,25 +17,9 @@ import qualified Text.Blaze.Html5.Attributes as A
|
||||
import Text.Blaze.Html.Renderer.Utf8
|
||||
import Data.Monoid
|
||||
import qualified Data.Set as Set
|
||||
import Source
|
||||
|
||||
type ClassName = String
|
||||
newtype Source a = Source (Int, [a])
|
||||
deriving (Eq, Show, Functor, Foldable)
|
||||
|
||||
makeSource :: [a] -> Source a
|
||||
makeSource list = Source (0, list)
|
||||
|
||||
unSource :: Source a -> [a]
|
||||
unSource (Source (_, list)) = list
|
||||
|
||||
subsource :: Range -> Source a -> Source a
|
||||
subsource range (Source (i, list)) = Source (start range, sublist (offsetRange (negate i) range) list)
|
||||
|
||||
toString :: Source Char -> String
|
||||
toString = unSource
|
||||
|
||||
at :: Source a -> Int -> a
|
||||
at = (!!) . unSource
|
||||
|
||||
classifyMarkup :: Foldable f => f String -> Markup -> Markup
|
||||
classifyMarkup categories element = maybe element ((element !) . A.class_ . stringValue . ("category-" ++)) $ maybeLast categories
|
||||
|
@ -10,6 +10,7 @@ import Test.QuickCheck hiding (Fixed)
|
||||
import Control.Comonad.Cofree
|
||||
import Control.Monad.Free hiding (unfold)
|
||||
import qualified Data.Maybe as Maybe
|
||||
import Source
|
||||
import Line
|
||||
import Row
|
||||
import Patch
|
||||
|
Loading…
Reference in New Issue
Block a user