2017-03-31 22:17:43 +03:00
|
|
|
{-# LANGUAGE ConstraintKinds, DataKinds, GeneralizedNewtypeDeriving #-}
|
2017-01-20 22:44:10 +03:00
|
|
|
module Info
|
2017-03-31 22:19:52 +03:00
|
|
|
( DefaultFields
|
|
|
|
, HasDefaultFields
|
2017-03-31 22:17:43 +03:00
|
|
|
, Range(..)
|
2017-02-16 19:58:26 +03:00
|
|
|
, byteRange
|
2017-05-05 16:32:15 +03:00
|
|
|
, setByteRange
|
2017-01-20 22:44:10 +03:00
|
|
|
, Category(..)
|
|
|
|
, category
|
|
|
|
, setCategory
|
|
|
|
, SourceSpan(..)
|
|
|
|
, SourcePos(..)
|
|
|
|
, SourceSpans(..)
|
2017-01-20 22:44:23 +03:00
|
|
|
, sourceSpan
|
|
|
|
, setSourceSpan
|
2017-01-20 22:44:10 +03:00
|
|
|
, SourceText(..)
|
|
|
|
, sourceText
|
|
|
|
) where
|
2016-03-31 00:26:52 +03:00
|
|
|
|
2016-06-17 17:26:20 +03:00
|
|
|
import Data.Record
|
2016-05-26 19:58:04 +03:00
|
|
|
import Prologue
|
2016-03-31 00:26:52 +03:00
|
|
|
import Category
|
|
|
|
import Range
|
2016-10-06 00:40:49 +03:00
|
|
|
import SourceSpan
|
2016-11-01 23:04:16 +03:00
|
|
|
import Data.Aeson
|
2016-03-31 00:26:52 +03:00
|
|
|
|
2017-03-31 22:19:52 +03:00
|
|
|
-- | The default set of fields produced by our parsers.
|
|
|
|
type DefaultFields = '[ Range, Category, SourceSpan ]
|
|
|
|
|
2017-03-31 22:17:43 +03:00
|
|
|
-- | A type alias for HasField constraints commonly used throughout semantic-diff.
|
2017-03-31 22:18:27 +03:00
|
|
|
type HasDefaultFields fields = (HasField fields Category, HasField fields Range, HasField fields SourceSpan)
|
2017-03-31 22:17:43 +03:00
|
|
|
|
2016-11-10 02:39:35 +03:00
|
|
|
newtype SourceText = SourceText { unText :: Text }
|
|
|
|
deriving (Show, ToJSON)
|
|
|
|
|
2017-02-16 19:58:26 +03:00
|
|
|
byteRange :: HasField fields Range => Record fields -> Range
|
|
|
|
byteRange = getField
|
2016-06-17 17:26:20 +03:00
|
|
|
|
2017-05-05 16:32:15 +03:00
|
|
|
setByteRange :: HasField fields Range => Record fields -> Range -> Record fields
|
|
|
|
setByteRange = setField
|
2016-06-17 17:29:24 +03:00
|
|
|
|
2016-06-17 20:33:50 +03:00
|
|
|
category :: HasField fields Category => Record fields -> Category
|
|
|
|
category = getField
|
2016-06-17 17:26:20 +03:00
|
|
|
|
2016-06-17 21:07:21 +03:00
|
|
|
setCategory :: HasField fields Category => Record fields -> Category -> Record fields
|
2016-06-17 20:33:50 +03:00
|
|
|
setCategory = setField
|
2016-06-17 17:29:24 +03:00
|
|
|
|
2017-01-20 22:41:34 +03:00
|
|
|
sourceText :: HasField fields SourceText => Record fields -> SourceText
|
|
|
|
sourceText = getField
|
|
|
|
|
2017-01-20 22:44:23 +03:00
|
|
|
sourceSpan :: HasField fields SourceSpan => Record fields -> SourceSpan
|
|
|
|
sourceSpan = getField
|
|
|
|
|
|
|
|
setSourceSpan :: HasField fields SourceSpan => Record fields -> SourceSpan -> Record fields
|
|
|
|
setSourceSpan = setField
|