Safe Haskell | None |
---|---|
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
Eq Source Source # | |
Show Source Source # | |
IsString Source Source # | |
Defined in Source.Source fromString :: String -> Source # | |
Generic Source Source # | |
Semigroup Source Source # | |
Monoid 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.0.0.0-inplace" True) (C1 (MetaCons "Source" PrefixI True) (S1 (MetaSel (Just "bytes") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString))) |
bytes :: Source -> ByteString Source #
fromUTF8 :: ByteString -> Source Source #
Measurement
En/decoding
Slicing
Splitting
newlineIndices :: ByteString -> [Int] Source #
Return all indices of newlines ('\n', '\r', and '\r\n') in the ByteString
.