From 91a1a1720b4959c2398704ab0a4e252694e3e283 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Fri, 31 Jan 2020 13:32:00 -0500 Subject: [PATCH] Fix documentation for Source.Span.Pos. Fixes #457. --- semantic-source/src/Source/Span.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/semantic-source/src/Source/Span.hs b/semantic-source/src/Source/Span.hs index 109f321d7..d71553af6 100644 --- a/semantic-source/src/Source/Span.hs +++ b/semantic-source/src/Source/Span.hs @@ -1,4 +1,6 @@ -{-# LANGUAGE DeriveGeneric, OverloadedStrings, RankNTypes #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RankNTypes #-} -- | Source position and span information -- -- Mostly taken from purescript's SourcePos definition. @@ -16,9 +18,9 @@ import Control.DeepSeq (NFData) import Data.Aeson ((.:), (.=)) import qualified Data.Aeson as A import Data.Hashable (Hashable) -import Data.Semilattice.Lower (Lower(..)) +import Data.Semilattice.Lower (Lower (..)) import GHC.Generics (Generic) -import GHC.Stack (SrcLoc(..)) +import GHC.Stack (SrcLoc (..)) -- | A Span of position information data Span = Span @@ -56,7 +58,11 @@ spanFromSrcLoc :: SrcLoc -> Span spanFromSrcLoc s = Span (Pos (srcLocStartLine s) (srcLocStartCol s)) (Pos (srcLocEndLine s) (srcLocEndCol s)) --- | Source position information (1-indexed) +-- | Source position information. +-- The 'Pos' values associated with ASTs returned from tree-sitter +-- 'Unmarshal' instances are zero-indexed. Unless you are displaying +-- span information to a user, you should write your code assuming +-- zero-indexing. data Pos = Pos { line :: {-# UNPACK #-} !Int , column :: {-# UNPACK #-} !Int