1
1
mirror of https://github.com/github/semantic.git synced 2025-01-07 07:58:12 +03:00
semantic/src/Info.hs

44 lines
1.2 KiB
Haskell
Raw Normal View History

2016-06-23 23:19:51 +03:00
{-# LANGUAGE DataKinds, GeneralizedNewtypeDeriving #-}
module Info (Range(..), characterRange, setCharacterRange, Category(..), category, setCategory, Cost(..), cost, setCost, SourceSpan(..), SourcePos(..), SourceSpans(..), SourceText(..), sourceText) where
2016-03-31 00:26:52 +03:00
2017-01-05 23:04:42 +03:00
import Data.Functor.Listable
import Data.Record
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
2016-08-18 17:52:49 +03:00
newtype Cost = Cost { unCost :: Int }
2016-11-01 23:04:16 +03:00
deriving (Eq, Num, Ord, Show, ToJSON)
newtype SourceText = SourceText { unText :: Text }
deriving (Show, ToJSON)
characterRange :: HasField fields Range => Record fields -> Range
characterRange = getField
setCharacterRange :: HasField fields Range => Record fields -> Range -> Record fields
setCharacterRange = setField
2016-06-17 17:29:24 +03:00
category :: HasField fields Category => Record fields -> Category
category = getField
setCategory :: HasField fields Category => Record fields -> Category -> Record fields
setCategory = setField
2016-06-17 17:29:24 +03:00
cost :: HasField fields Cost => Record fields -> Cost
cost = getField
setCost :: HasField fields Cost => Record fields -> Cost -> Record fields
setCost = setField
sourceText :: HasField fields SourceText => Record fields -> SourceText
sourceText = getField
-- Instances
2017-01-05 23:04:42 +03:00
instance Listable Cost where
tiers = cons1 Cost