Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Source
models source code, represented as a thin wrapper around a ByteString
with conveniences for splitting by line, slicing, etc.
This module is intended to be imported qualified to avoid name clashes with Prelude
:
import qualified Source.Source as Source
Synopsis
- data Source
- bytes :: Source -> ByteString
- fromUTF8 :: ByteString -> Source
- length :: Source -> Int
- null :: Source -> Bool
- totalRange :: Source -> Range
- totalSpan :: Source -> Span
- fromText :: Text -> Source
- toText :: Source -> Text
- slice :: Source -> Range -> Source
- drop :: Int -> Source -> Source
- take :: Int -> Source -> Source
- lines :: Source -> [Source]
- lineRanges :: Source -> [Range]
- lineRangesWithin :: Source -> Range -> [Range]
- newlineIndices :: ByteString -> [Int]
Documentation
The contents of a source file. This is represented as a UTF-8
ByteString
under the hood. Construct these with fromUTF8
; obviously,
passing fromUTF8
non-UTF8 bytes will cause crashes.
Instances
IsString Source Source # | |
Defined in Source.Source fromString :: String -> Source | |
Monoid Source Source # | |
Semigroup Source Source # | |
Generic Source Source # | |
Show Source Source # | |
NFData Source Source # | |
Defined in Source.Source | |
Eq Source Source # | |
FromJSON Source Source # | |
Defined in Source.Source parseJSON :: Value -> Parser Source parseJSONList :: Value -> Parser [Source] | |
type Rep Source Source # | |
Defined in Source.Source type Rep Source = D1 ('MetaData "Source" "Source.Source" "semantic-source-0.1.0.2-inplace" 'True) (C1 ('MetaCons "Source" 'PrefixI 'True) (S1 ('MetaSel ('Just "bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
Measurement
En/decoding
Slicing
Splitting
newlineIndices :: ByteString -> [Int] Source #
Return all indices of newlines ('n', 'r', and 'rn') in the ByteString
.