1
1
mirror of https://github.com/github/semantic.git synced 2025-01-05 05:58:34 +03:00

🔥 LocatedValue.

This commit is contained in:
Rob Rix 2018-03-29 22:11:58 -04:00
parent 65af3ad238
commit 1b90003f6f

View File

@ -1,15 +1,10 @@
{-# LANGUAGE TypeFamilies #-}
module Data.Abstract.Located where
import Control.Abstract.Evaluator
import Control.Abstract.Value
import Data.Abstract.Address
import Data.Bifunctor
import Data.Range
import Data.Record
import Data.Span
import Prelude hiding (null)
import Prologue hiding (hash, null)
-- TODO: Dependencies
type Provenance = Record '[Range, Span]
@ -20,23 +15,3 @@ data Located location = Located { provenance :: !Provenance, location :: locatio
instance Location location => Location (Located location) where
type Cell (Located location) = Cell location
newtype LocatedValue value = LocatedValue { unLocatedValue :: value }
deriving (Eq, Ord, Show)
instance MonadValue (Located location) value m => MonadValue (Located location) (LocatedValue value) m where
unit = LocatedValue <$> unit
null = LocatedValue <$> null
integer = fmap LocatedValue . integer
float = fmap LocatedValue . float
rational = fmap LocatedValue . rational
boolean = fmap LocatedValue . boolean
multiple = fmap LocatedValue . multiple . map unLocatedValue
string = fmap LocatedValue . string
symbol = fmap LocatedValue . symbol
array = fmap LocatedValue . array . map unLocatedValue
hash = fmap LocatedValue . hash . map (bimap unLocatedValue unLocatedValue)
ifthenelse = ifthenelse . unLocatedValue
kvPair = fmap (fmap LocatedValue) . (kvPair `on` unLocatedValue)
-- klass name vals env = LocatedValue <$> klass name (map unLocatedValue vals) (fmap unLocatedValue env)