From 9a36f7979fa1e68062e8e6cb9970d0f306314491 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 29 Mar 2018 10:04:43 -0400 Subject: [PATCH] Stub in part of a MonadValue instance for now --- src/Data/Abstract/Located.hs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Data/Abstract/Located.hs b/src/Data/Abstract/Located.hs index ac599027e..4ca87e016 100644 --- a/src/Data/Abstract/Located.hs +++ b/src/Data/Abstract/Located.hs @@ -2,10 +2,14 @@ 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] @@ -23,3 +27,19 @@ newtype LocatedValue value = LocatedValue { unLocatedValue :: value } instance AbstractValue (LocatedValue value) where type LocationFor (LocatedValue value) = Located (LocationFor value) + +instance MonadValue value m => MonadValue (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)