-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1559 from GaloisInc/T1455
Make names in scope in functors accessible when their instantiations are loaded at the REPL
- Loading branch information
Showing
48 changed files
with
2,124 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{-# LANGUAGE DeriveAnyClass #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Cryptol.ModuleSystem.NamingEnv.Types where | ||
|
||
import Data.Map.Strict (Map) | ||
import qualified Data.Map.Strict as Map | ||
|
||
import Control.DeepSeq (NFData) | ||
import GHC.Generics (Generic) | ||
|
||
import Cryptol.ModuleSystem.Names | ||
import Cryptol.Parser.Name | ||
import Cryptol.Utils.Ident | ||
import Cryptol.Utils.PP | ||
|
||
-- | The 'NamingEnv' is used by the renamer to determine what | ||
-- identifiers refer to. | ||
newtype NamingEnv = NamingEnv (Map Namespace (Map PName Names)) | ||
deriving (Show,Generic,NFData) | ||
|
||
instance Monoid NamingEnv where | ||
mempty = NamingEnv Map.empty | ||
{-# INLINE mempty #-} | ||
|
||
instance Semigroup NamingEnv where | ||
NamingEnv l <> NamingEnv r = | ||
NamingEnv (Map.unionWith (Map.unionWith (<>)) l r) | ||
|
||
instance PP NamingEnv where | ||
ppPrec _ (NamingEnv mps) = vcat $ map ppNS $ Map.toList mps | ||
where ppNS (ns,xs) = nest 2 (vcat (pp ns : map ppNm (Map.toList xs))) | ||
ppNm (x,as) = pp x <+> "->" <+> commaSep (map pp (namesToList as)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.