1
1
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:
Rob Rix 2019-09-20 14:16:42 -04:00
parent 81f43c9881
commit 2748529c13
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7
2 changed files with 35 additions and 5 deletions

View File

@ -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

View 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 #-}