From 2eb78e8f91ba64b95cc01252816d3998fe10b407 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 May 2018 08:56:42 -0400 Subject: [PATCH] Define unName as a function rather than a field selector. --- src/Data/Abstract/Environment.hs | 2 +- src/Data/Abstract/FreeVariables.hs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Data/Abstract/Environment.hs b/src/Data/Abstract/Environment.hs index b30b6f466..f8e11b380 100644 --- a/src/Data/Abstract/Environment.hs +++ b/src/Data/Abstract/Environment.hs @@ -85,7 +85,7 @@ mergeNewer (Environment a) (Environment b) = -- | Extract an association list of bindings from an 'Environment'. -- -- >>> pairs shadowed --- [(Name {unName = "foo"},Address {unAddress = Precise 1)] +-- [(Name "foo",Address {unAddress = Precise 1)] pairs :: Environment location value -> [(Name, Address location value)] pairs = map (second Address) . Map.toList . fold . unEnvironment diff --git a/src/Data/Abstract/FreeVariables.hs b/src/Data/Abstract/FreeVariables.hs index baa1851b6..2dcd58ebc 100644 --- a/src/Data/Abstract/FreeVariables.hs +++ b/src/Data/Abstract/FreeVariables.hs @@ -8,12 +8,15 @@ import Data.Term import Prologue -- | The type of variable names. -newtype Name = Name { unName :: ByteString } +newtype Name = Name ByteString deriving (Eq, Ord, Show) name :: ByteString -> Name name = Name +unName :: Name -> ByteString +unName (Name bytes) = bytes + instance IsString Name where fromString = Name . BC.pack