mirror of
https://github.com/github/semantic.git
synced 2024-12-24 23:42:31 +03:00
Copy Location in as Loc.
This commit is contained in:
parent
81f43c9881
commit
2748529c13
@ -39,16 +39,18 @@ common common
|
||||
library
|
||||
import: common
|
||||
exposed-modules:
|
||||
Source.Loc
|
||||
Source.Range
|
||||
Source.Span
|
||||
-- other-modules:
|
||||
-- other-extensions:
|
||||
build-depends:
|
||||
aeson ^>= 1.4.2.0
|
||||
, base >= 4.12 && < 5
|
||||
, deepseq ^>= 1.4.4.0
|
||||
, hashable ^>= 1.2.7.0
|
||||
, semilattices ^>= 0.0.0.3
|
||||
aeson ^>= 1.4.2.0
|
||||
, base >= 4.12 && < 5
|
||||
, deepseq ^>= 1.4.4.0
|
||||
, generic-monoid ^>= 0.1.0.0
|
||||
, hashable ^>= 1.2.7.0
|
||||
, semilattices ^>= 0.0.0.3
|
||||
hs-source-dirs: src
|
||||
|
||||
test-suite doctest
|
||||
|
28
semantic-source/src/Source/Loc.hs
Normal file
28
semantic-source/src/Source/Loc.hs
Normal file
@ -0,0 +1,28 @@
|
||||
{-# LANGUAGE DeriveGeneric, DerivingVia #-}
|
||||
module Source.Loc
|
||||
( Loc(..)
|
||||
, Span(..)
|
||||
, Range(..)
|
||||
) where
|
||||
|
||||
import Control.DeepSeq (NFData)
|
||||
import Data.Hashable (Hashable)
|
||||
import Data.Monoid.Generic
|
||||
import GHC.Generics (Generic)
|
||||
import Source.Range
|
||||
import Source.Span
|
||||
|
||||
data Loc = Loc
|
||||
{ locByteRange :: {-# UNPACK #-} !Range
|
||||
, locSpan :: {-# UNPACK #-} !Span
|
||||
}
|
||||
deriving (Eq, Ord, Show, Generic)
|
||||
deriving Semigroup via GenericSemigroup Loc
|
||||
|
||||
instance Hashable Loc
|
||||
instance NFData Loc
|
||||
|
||||
instance HasSpan Loc where
|
||||
span = lens locSpan (\l s -> l { locSpan = s }) where
|
||||
lens get put afa s = fmap (put s) (afa (get s))
|
||||
{-# INLINE span #-}
|
Loading…
Reference in New Issue
Block a user