mirror of
https://github.com/github/semantic.git
synced 2024-12-22 06:11:49 +03:00
Define unAddress as a function rather than a field selector.
This commit is contained in:
parent
5cfa7028e7
commit
d1c465ab14
@ -9,9 +9,12 @@ import Data.Semilattice.Lower
|
||||
import Prologue
|
||||
|
||||
-- | An abstract address with a @location@ pointing to a variable of type @value@.
|
||||
newtype Address location value = Address { unAddress :: location }
|
||||
newtype Address location value = Address location
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
unAddress :: Address location value -> location
|
||||
unAddress (Address location) = location
|
||||
|
||||
instance Eq location => Eq1 (Address location) where liftEq _ a b = unAddress a == unAddress b
|
||||
instance Ord location => Ord1 (Address location) where liftCompare _ a b = unAddress a `compare` unAddress b
|
||||
instance Show location => Show1 (Address location) where liftShowsPrec _ _ = showsPrec
|
||||
|
@ -95,7 +95,7 @@ unpairs = fromList
|
||||
-- | Lookup a 'Name' in the environment.
|
||||
--
|
||||
-- >>> lookup (name "foo") shadowed
|
||||
-- Just (Address {unAddress = Precise 1})
|
||||
-- Just (Address (Precise 1))
|
||||
lookup :: Name -> Environment location value -> Maybe (Address location value)
|
||||
lookup k = fmap Address . foldMapA (Map.lookup k) . unEnvironment
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user