1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 14:21:31 +03:00

Define unName as a function rather than a field selector.

This commit is contained in:
Rob Rix 2018-05-11 08:56:42 -04:00
parent d1c465ab14
commit 2eb78e8f91
2 changed files with 5 additions and 2 deletions

View File

@ -85,7 +85,7 @@ mergeNewer (Environment a) (Environment b) =
-- | Extract an association list of bindings from an 'Environment'. -- | Extract an association list of bindings from an 'Environment'.
-- --
-- >>> pairs shadowed -- >>> pairs shadowed
-- [(Name {unName = "foo"},Address {unAddress = Precise 1)] -- [(Name "foo",Address {unAddress = Precise 1)]
pairs :: Environment location value -> [(Name, Address location value)] pairs :: Environment location value -> [(Name, Address location value)]
pairs = map (second Address) . Map.toList . fold . unEnvironment pairs = map (second Address) . Map.toList . fold . unEnvironment

View File

@ -8,12 +8,15 @@ import Data.Term
import Prologue import Prologue
-- | The type of variable names. -- | The type of variable names.
newtype Name = Name { unName :: ByteString } newtype Name = Name ByteString
deriving (Eq, Ord, Show) deriving (Eq, Ord, Show)
name :: ByteString -> Name name :: ByteString -> Name
name = Name name = Name
unName :: Name -> ByteString
unName (Name bytes) = bytes
instance IsString Name where instance IsString Name where
fromString = Name . BC.pack fromString = Name . BC.pack